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.
| Author |
Topic |
|
csphard
Posting Yak Master
113 Posts |
Posted - 2005-11-18 : 13:44:26
|
| I used order by newid() with top 200 to get 200 records in random order and it works. Now they are asking well you got the information but Its not in order. newid allows me to select my information which results 10000 - 15000recordsorder by newid randomly sorts it and then I get the top 200. Is there a way to get that top 200 and then sort it by something?thanksSELECT top 5FROM Northwind..Orders ORDER BY NEWID() |
|
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
Posted - 2005-11-18 : 13:53:49
|
Sure, you can make the initial query a derived table and then sort the results. Something like:select d.<column1>, d.<column2>from( SELECT top 5 <column1>, <column2> FROM <table> ORDER BY NEWID()) dorder by d.<column1> |
 |
|
|
|
|
|