Here's another, same caveats apply
WITH CTE AS
(
SELECT id,grp,dte,
ROW_NUMBER() OVER(ORDER BY dte ASC, grp) AS rn
FROM @tbl tbl
),
CTE2 AS (
SELECT id,grp,dte,rn,
MIN(rn) OVER(PARTITION BY grp) AS MinRn
FROM CTE)
SELECT id,grp,dte
--,rn,MinRn
FROM CTE2
WHERE MinRn <= 8
ORDER BY rn;
____________________________________________________
Deja View - The strange feeling that somewhere, sometime you've optimised this query before
How to get the best help on a forum
http://www.sqlservercentral.com/articles/Best+Practices/61537