SQL Query........... [Resolved]

Posted by Somu475 under Sql Server on 12/4/2012 | Points: 10 | Views : 1167 | Status : [Member] | Replies : 2
Hi All,

I have a table named Student with columns StudId, Subject, Marks.

1 maths 65
1 English 90
1 Social 55
1 Kannada 60
1 Computer 85
2 maths 55
2 English 63
2 social 55
2 Kannada 90
2 Computer 70
3 Maths 80
3 English 30
3 Social 75
3 Kannada 60
3 Computer 45


I want to find the highest of marks of each student in subject.
i.e O/P should be like this

1 English 90
2 Kannada 90
3 Maths 80


Please help me...

-Somu


Responses

Posted by: Manoj_B on: 12/4/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hii..

Your sql query is:-

select a.id,b.subject,a.mark from (select id,MAX(mark)Mark from tblTest group by id)a inner join tblTest b on a.mark=b.mark and a.id=b.id




Thanks & Regards
Manoj Kumar

Somu475, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Somu475 on: 12/4/2012 [Member] Starter | Points: 25

Up
0
Down
Thanks a lot....
ORDER BY was missing in ur query, by adding that I got the o/p as I needed...

-Somu

Somu475, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response