Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
cool_moon
Starting Member
26 Posts |
Posted - 2003-02-17 : 03:56:17
|
hi there.... I want to know the query to see the records for TOP 3 "Student" of EACH "Class" of EACH "Section"....!!!thanx in advance.take care,God Bless You All. |
|
Arnold Fribble
Yak-finder General
1961 Posts |
|
cool_moon
Starting Member
26 Posts |
Posted - 2003-02-22 : 04:14:57
|
Thanx but i have found out the query for finding the TOP 3 records by the following query......!SELECT S.StudentName, S.StudentClass, S.Section, S.MarkObtainedFROM Students as SWHERE S.RollNumber In (SELECT TOP 3 SR.RollNumber FROM Students as SR WHERE (SR.StudentClass = S.StudentClass) ORDER BY MarkObtained DESC)ORDER BY S.StudentClass,S.MarkObtained DESC |
 |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-02-22 : 23:17:33
|
That is a really great way to get the top 3 for each group .... very cool !! I am going to need to investigate that technique a little more.I am surprise that a subquery in the WHERE clause can itself have a WHERE clause that refers back to the main query!- Jeff |
 |
|
|
|
|