SQL: Find the max record per group
Posted
by user319088
on Stack Overflow
See other posts from Stack Overflow
or by user319088
Published on 2010-04-17T06:19:45Z
Indexed on
2010/04/17
6:33 UTC
Read the original article
Hit count: 268
I have one table, which has three fields and data.
Name , Top , Total cat , 1 , 10 dog , 2 , 7 cat , 3 , 20 horse , 4 , 4 cat , 5 , 10 dog , 6 , 9
I want to select the record which has highest value of Total
for each Name
, so my result should be like this:
Name , Top , Total cat , 3 , 20 horse , 4 , 4 Dog , 6 , 9
I tried group by name order by total, but it give top most record of group by result. Can anyone guide me, please?
© Stack Overflow or respective owner