Skip to content
Prev 25256 / 398502 Next

How to sample database

In postgresql, one way to take a random sample is using the random()
function with a limit on the number of rows returned. It is something
like:

    select * from mydb
    order by random()
    limit 100;

Perhaps mysql has a similar RANDOM() function that can be used for
sorting by a random field. 

Loren
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._