Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
We have a table that contains a list of questions, and each question is associated with a teamid, question, team. What we are trying to do, is return ten questions that only correspond to one team. e.g. there are 16 teams, but return 10 questions, with only 1 question per team showing. Making them return randomly is also handy.
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2009-01-18 : 22:51:04
just use
SELECT id,question,teamFROM(SELECT ROW_NUMBER() OVER(PARTITION BY team ORDER BY NEWID()) AS Seq,*FROM Table)tWHERE t.Seq=1