Click to See Complete Forum and Search --> : SQl Query - Distinct records with Max Value


sr_aneesh
October 25th, 2004, 01:12 PM
I have the following records

ID Name Marks
1 Ronnie 50
2 Mark 50
3 Ronnie 52
4 Ronnie 56
5 John 52
6 Mark 12
7 Mark 9

what query should be written to retreive distinct Name with Maximum Marks

That is
The Out Put should be

Name Marks
Ronnie 56
John 52
Mark 62

Thanx in advance
Aneesh

khp
October 26th, 2004, 01:03 AM
In mysql one would write something like
SELECT Name, MAX(Marks) AS Marks FROM table GROUP BY Name