P Kishor <[EMAIL PROTECTED]> wrote:
> On 2/4/08, Piotr Budny
> <[EMAIL PROTECTED]> wrote:
>> Now, I want to get the ID for such max rows:
>>
>> select id,name,max(weight) from test group by name;
>
> sqlite> select t.* from test t join (select name, max(weight) as m
> from test group by name) w on t.weight = w.m and t.name = w.name;
> 15|C|123
> 2|A|50
> 3|B|1
> sqlite>

Beware of ties (two or more rows in the same group sharing the largest 
weight).

Igor Tandetnik 



_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to