Re: Stochastic Queries

From: Jason Lepack <jlepack_at_gmail.com>
Date: Mon, 10 Sep 2007 05:26:47 -0700
Message-ID: <1189427207.860790.38670_at_w3g2000hsg.googlegroups.com>


It depends... I don't know of any "good" methods using ANSI SQL, but there are methods that can be used depending on what type of SQL you are using.

Try google... I found all of these solutions by typing into Google: "language-name" random records

In T-SQL there's the newid() method:
http://www.sqlteam.com/article/using-newid-to-randomly-sort-records

Oracle has sample():
http://www.adp-gmbh.ch/ora/sql/examples/select_sample.html

MySQL has rand():
http://webxadmin.free.fr/article/mysql-random-records-170.php

Cheers,
Jason Lepack

On Sep 10, 2:21 am, Joe Thurbon <use..._at_thurbon.com> wrote:
> As a part of some experimental work I've been doing, I need to write
> what I think is best described as a stochastic quota query.
>
> I would like to write a query like
>
> SELECT RANDOM 5 COLUMN_FOO FROM TABLE_BAR
>
> where RANDOM is like TOP, except that for successive queries, I get a
> (possibly) different set of 5 COLUMN_FOO values from table TABLE_BAR.
>
> Has anyone seen such a beast?
>
> Thanks in advance,
> Joe
Received on Mon Sep 10 2007 - 14:26:47 CEST

Original text of this message