I have a table 'table1' with fields, 'key' and 'number'
There is another table 'table2' with fields 'key1' and 'key2'
'table2.key1' corresponds to 'table1.key'.
Now, I need to find, in one query, the sum of all 'table1.number' fields for a given 'table2.key2' AND the highest sum of 'table1.number' with same key, within the 'table2.key2'


So I need something like
SELECT sum(table1.number) as highest FROM table1, table2 WHERE table1.key=table2.key1 AND table2.key2=? GROUP BY table1.key ORDER BY highest DESC LIMIT 1
and
SELECT sum(table1.number) as total FROM table1, table2 WHERE table1.key=table2.key2 AND table2.key2=? GROUP BY table2.key2
in one query.


Is this even possible?
I would greatly appreciate any help, thanks

Aleksander Wang-Hansen

_________________________________________________________________
MSN Messenger http://www.msn.no/messenger - Den korteste veien mellom deg og dine venner



-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to