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.

 All Forums
 Other Forums
 MS Access
 [Req]Top 3 records in each class....!!!

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

Posted - 2003-02-17 : 05:51:49
Lots of good stuff in this thread:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=21431


Go to Top of Page

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.MarkObtained
FROM Students as S
WHERE 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

Go to Top of Page

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
Go to Top of Page
   

- Advertisement -