Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

random rows 2

Status
Not open for further replies.

nyzja

Programmer
Jan 13, 2005
31
US
Hi! I have a view based on 3 tables. Now, out of the result, I need to randomly pick 5 ID's. I'm trying to use RAND but don't really know how to use it on the ID's or if it's even possible. Is there a way to randomly select an ID or a row from a view (or a temp table, whichever will work)?


Please help! Thanks!
 
Insert the data into a temp table which also has a uniqueidentifier field in it, populated using the newid function. Then sort on this field and pick the top 5 records. Look up newid for how to set up the table using newid().

Questions about posting. See faq183-874
Click here to help with Hurricane Relief
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top