Quick question,
select
MAX(field), field2, SUM(field3),
from
table
where CONDITION
group by field2
This obviously gives me the maximum value of the group field2. However, of all the groups that will be returned, there will also be a max value among SUM(field3).
I don't mind doing two separate queries, and in an UGLY way I can do this:
select
SUM(field3) as findMax
from
table
where CONDITION
group by field2,
order by findMax DESC
And of course in this case the first value is the max because I sorted DESCENDING.
It just seems there's a more elegant approach to say: "give me the max value of a sum function on a field, where the records are broken into such-and-such groups"
Thank you,
Sam Fullman