Re: How to select random rows from a table

From: Joel Garry <joelga_at_rossinc.com>
Date: 1996/10/02
Message-ID: <1996Oct2.224158.24182_at_rossinc.com>#1/1


In article <32514F42.5A5C_at_cmprime.cis.att.com> Michael Serbanescu <ms_at_cmprime.cis.att.com> writes:
>Although I am not happy with the suggestion below, because it is
>ORACLE-specific, try it anyway:
>
>select * from <table_name>
>where rownum=1;
>
>Note that you _must_ have rownum=1; otherwise, the query will not
>retrieve any rows.
>
>
I would think you would not be happy because it gives the first row of the table, rather than a random row.
>I hope this helps.
>
>
>Michael Serbanescu
>Sr. ORACLE DBA, TRECOM Business Systems, Edison, NJ
>ms_at_cmprime.cis.att.com
>(908)576-3894
>-------------------------------------------------------------------------------
>Paul Tame wrote:
>>
>> I have a requirement to fetch a single row randomly from a table. Does
>> anyone have a neat solution without fetching all the rows back to 'C' and
>> using a 'C' routine to randomly identify a row?

-- 
Joel Garry               joelga_at_rossinc.com               Compuserve 70661,1534
These are my opinions, not necessarily those of Ross Systems, Inc.   <> <>
%DCL-W-SOFTONEDGEDONTPUSH, Software On Edge - Don't Push.            \ V /
panic: ifree: freeing free inodes...                                   O
Received on Wed Oct 02 1996 - 00:00:00 CEST

Original text of this message