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 2005 Forums
 Transact-SQL (2005)
 Round robin select

Author  Topic 

Masum7
Starting Member

33 Posts

Posted - 2009-06-04 : 00:07:02
I have a table like this:

table resource:
id userid
1 1
2 1
3 2
4 3
5 3
6 3
7 1
8 2

Here id is pkey. Now I want to select rows from the table in round robin fashion based with respect to userid.

I mean the select query will select id, userid in such a way output is like this:
1 1
3 2
4 3
2 1
8 2
5 3
7 1
6 3

So you see from the result userid comes 1, 2, 3 then again 1, 2, 3. Then 2 finishes. It comes only with 3.

Masum

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-04 : 00:19:20
Duplicate post.
Please continue here http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=127021


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -