Click here to Skip to main content
15,889,527 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
SQL
Table:

id--Subject--Marks
1-----a-------1
2-----a-------2
3-----b-------4
4-----b-------3
5-----b-------2
6-----c-------6
7-----d-------8
8-----d-------1


select id from each subject where max(marks)

Answer:

id
2
3
6
7
Posted
Comments
[no name] 27-Aug-13 10:27am    
Not a question or a description of any kind of a problem.

 
Share this answer
 
SQL
select s.id from subject s inner join (
select subject, MAX(marks) as marks
from subject
group by subject) dt
on s.subject = dt.subject
and s.marks = dt.marks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900