>Hi
>
>I have the following table
>
>Stud_ID Faculty Points
>----------- ---------- ---------
>001 ARTS 90
>002 ARTS 87
>003 ENG 87
>006 LAW 78
>
>I wish to extract the top 2 students of each faculty
>
>I would appreciate if you could help me with the SQL
>
>Thanks & Best Regards
This is very complex query in VFP, but Sergey has solved it before here
Re: Select top 3 within a group Thread #
1129690 Message #
1129692So, the query will be
SELECT * FROM csrFacilities mt1 ;
WHERE NOT EXISTS (SELECT * FROM csrFacilities mt2 ;
WHERE mt2.Faculty = mt1.Faculty ;
AND mt2.Points > mt1.Points;
HAVING COUNT(*) >= 2)
If it's not broken, fix it until it is.
My Blog