[snip]
I have a simple table

col1  col2    col3
A      2          3
A      100      70
A      1000    80
B        20       90
B        70        80


To select the top one row for each unique value of col1

select distinct on (col1), col1, col2, col3
from table
order by col1, col2 desc, col3 desc;

What I want is
A  1000 80
B   70     80

How do you do it in mysql?
[/snip]

The same way you do it inother SQL's.

SELECT MAX(col2) FROM table GROUP BY col1;

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

Reply via email to