I have this table where the columns and rows are organized like this:
+------+------+ | a | b | +------+------+ | 1 | 1 | | 2 | 1 | | 2 | 2 | | 2 | 3 | | 2 | 4 | | 3 | 1 | | 3 | 2 | +------+------+
I want to run a select that gives me one row for each unique value of
'a'. And in the cases where several rows exists for one single value of
'a', I require the rows with the largest values of 'b'. In SQL lingo that would be DISTINCT A and MAX(B), but I dont know how to write this into one select...
I.e. if I would apply these rules on the set above, I should get the following result:
+------+------+ | a | b | +------+------+ | 1 | 1 | | 2 | 4 | | 3 | 2 | +------+------+
Does anyone know how to formalize this request into a single SELECT statement (using mysql 4.0.13), please?
Regards, Svein Seldal
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]