|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Thursday, October 16, 2008 8:53 AM
Points: 22,
Visits: 49
|
|
I need to select random 5% rows from 100 records. The Select Top (5) percent gives me the first 5 rows. I want a random 5% but not in order. Any suggestions ?
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Yesterday @ 9:42 AM
Points: 2,891,
Visits: 5,858
|
|
Just select your top 5 percent rows and order by NEWID()
To help us help you read this
For better help with performance problems please read this
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Wednesday, May 08, 2013 7:42 AM
Points: 2,802,
Visits: 7,103
|
|
Even easier use the TABLESAMPLE funciton in sql 2005
select * from MyTable tablesample(5 percent)
there are some limitations on this though check BOL, the smaller the number of rows in your table the less accurate the % sample will be.
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Thursday, October 16, 2008 8:53 AM
Points: 22,
Visits: 49
|
|
| thanks but this did not get 5%
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Thursday, October 16, 2008 8:53 AM
Points: 22,
Visits: 49
|
|
|
|
|