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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Selecting top N from each type

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-10-16 : 18:06:00
Kaa writes "Hello Team,

Say I have a table where one of the fields define the type of the row. The type is dynamic, in that I might add a type or remove a type at anytime, the type is also not neccessarily sequential either. Now, in my table I have 15 rows of type A, 12 rows of type B and 4 rows of type C.

I wish to select say 5 rows of each type, no more but possibly less. I.e the recordset returned after querying should in this case contain 5 rows with type A, 5 rows with type B, and 4 rows with type C, preferably sorted within their groups accoring to other criteria.

Thanks for listening.

(MSSQL 2000 (preview)/ MSSQL 7 under Win2000)"
   

- Advertisement -