|>

|> I would like to select out the rows such that the sum of these rows is

|> less than some upper limit. Is this possible in SQL?

|>

|> select ...

|> from ...

|> where ...

|> and sum(x) <= LIMIT /* Select while the sum(x) is <= LIMIT */

|> order by date, ...

|>

|> This might be used, for example, to determine how long it took to

|> make $100.00.

|>

|> -Mike

Try the following:

SELECT col1, col2, SUM(col3)

FROM tablename

ORDER BY col1, col2

HAVING SUM(col3) <= SOME_LIMIT

Teresa Larson

+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+

| Teresa A. Larson - Hughes STX Corporation |

| NASA/GSFC Code 933.0 voice: (301) 286-7867 |

| Greenbelt, Maryland 20771 fax: (301) 286-1777 |

+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+