[thelist] SQL Help

Joshua Olson joshua at waetech.com
Fri Feb 13 23:26:17 CST 2004


> -----Original Message-----
> From: David Mitchell
> Sent: Friday, February 13, 2004 11:47 AM
>
> I have a table where each row is a budget entry. There is a column
> called "notifications" which is an int, and is between 0 and 6. I have
> to sum the money values for rows based on certain criteria, BUT I can
> only sum rows of the highest notification number. I tried something like:
>
> "SELECT SUM(cash) FROM budgetitem WHERE [seach criteria...] AND
> MAX(notification)"

This is a pretty tough problem if you don't have sub-selects or don't want
to make two queries.  Here's a solution with a subselect:

SELECT SUM(cash)
FROM budgetitem
WHERE [search criteria...]
AND notification = (SELECT MAX(notification) FROM budgetitem)

It you don't have subselects, it's a lot trickier, so let me know and I'll
post a solution if possible.

<><><><><><><><><><>
Joshua Olson
Web Application Engineer
WAE Tech Inc.
http://www.waetech.com/service_areas/
706.210.0168




More information about the thelist mailing list