Select Top 3 col1, col2, col3, col4, ...
From table
Order By col1, col2, ... Terry L. Broadbent FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
Use a correlated sub query to select the top three by group and the outer query to select for all groups.
SELECT t1.groupid, t1.col2, t1.col3, ...
FROM table t1
WHERE t1.col2 IN
(SELECT TOP 3 t2.col2 FROM table t2
WHERE t2.groupid=t1.groupid)
ORDER BY t1.groupid, t1.col2;
Terry L. Broadbent FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.