I am doing a website for a group of real estate agents. When showing the first search page we display the 10st properties on page 2 properties 11th to 20, etc. All the paging is beeing handled by the application.The trick is that my user wants that properties appear one per agent sorted randomly. I know how to do the random part but I can't figure out the select to alternate one property by agent. DECLARE @TT table( Pr_Id int, Pr_RealEstateAgent_Id int)INSERT INTO @TT VALUES ( 1, 1)INSERT INTO @TT VALUES ( 2, 2)INSERT INTO @TT VALUES ( 3, 1)INSERT INTO @TT VALUES ( 4, 3)INSERT INTO @TT VALUES ( 5, 1)INSERT INTO @TT VALUES ( 6, 1)INSERT INTO @TT VALUES ( 7, 1)INSERT INTO @TT VALUES ( 8, 2)INSERT INTO @TT VALUES ( 9, 2)INSERT INTO @TT VALUES ( 10, 4)INSERT INTO @TT VALUES ( 11, 5)INSERT INTO @TT VALUES ( 12, 3)INSERT INTO @TT VALUES ( 13, 5)INSERT INTO @TT VALUES ( 14, 3)INSERT INTO @TT VALUES ( 15, 3)Select Pr_RealEstateAgent_Id,Pr_Id FROM @TT
Expected result (without randomizing the agents)1 12 83 44 105 111 32 93 125 131 52 23 141 63 151 7
jean-lucwww.corobori.com