Ok, my brain is fried and need some extra eyes and brains....
I have a table with three fields
EmailID (int and identity)
Ok, lets says that in the table are 3000 records for ProjID 1454, 50 records for ProjID 1455, and 2 records for ProjID 1456 (all have the same status =100)
What I need to do in a set based solution (I can accomplish it in a cursor or temp table format but want something faster...) is Select the Top 200 records for each ProjID where emailStatus=100.
I have been trying varying combinations of Top N and Group by to no avail. Basically the query should return 200 records for ProjID 1454, the 50 records for 1455 and the 2 records for 1456.
Again, I have code to do this via a cursor and temp tables but want to see about a set based solution. (We are on SQL 2000)