Home All Groups Group Topic Archive Search About
Author
15 Jul 2005 11:19 PM
Lianne Kwock
Is there a function to randomly select certain percent of the data from a
table each time?

Author
15 Jul 2005 11:44 PM
--CELKO--
Not in SQL.  You really need to use a Stat package that can interface
with the RDBMS.  It will have all of the corrections that you need for
a proper sample.
Author
16 Jul 2005 12:46 AM
Lianne Kwock
What is a Stat Package?

Show quote
"--CELKO--" wrote:

> Not in SQL.  You really need to use a Stat package that can interface
> with the RDBMS.  It will have all of the corrections that you need for
> a proper sample.
>
>
Author
16 Jul 2005 1:05 AM
--CELKO--
Statistical package -- SAS, SPSS, etc.
Author
16 Jul 2005 4:39 AM
Louis Davidson
Not easily in 2000.  A trick is to do some thing like this would be
(assuming you want 25% of a 100 row table)

select top 25 *
from table
order by newid()

It doesn't give you all of the performance improvements of a proper sampling
function (since a sort will be required on a newly introduced value) but it
should give you all of the other characteristics.

--
----------------------------------------------------------------------------
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP


Show quote
"Lianne Kwock" <LianneKw***@discussions.microsoft.com> wrote in message
news:8B65E57D-4CB5-4626-8085-435ED6C2C228@microsoft.com...
> Is there a function to randomly select certain percent of the data from a
> table each time?
Author
16 Jul 2005 5:33 AM
Jens Süßmeyer
You could something like that

Select TOP 5
from Sometable
order by New_id()

HTH, Jens Suessmeyer.

Show quote
"Lianne Kwock" <LianneKw***@discussions.microsoft.com> wrote in message
news:8B65E57D-4CB5-4626-8085-435ED6C2C228@microsoft.com...
> Is there a function to randomly select certain percent of the data from a
> table each time?
Author
18 Jul 2005 8:03 PM
Thomas Coleman
Sure,

Select TOP 25 Percent Col1, Col2,....
From Table
Where....
Order By...

The Order By statement is obviously key to returning the expected results.


Thomas

Show quote
"Lianne Kwock" <LianneKw***@discussions.microsoft.com> wrote in message
news:8B65E57D-4CB5-4626-8085-435ED6C2C228@microsoft.com...
> Is there a function to randomly select certain percent of the data from a
> table each time?

AddThis Social Bookmark Button