Home > PL/SQL > [PLSQL] Select a random row from a database table

[PLSQL] Select a random row from a database table

Friday, 5 February, 2010 Leave a comment Go to comments

There is some way to select a random record or row from a database table.

SELECT col1, col2, col3  FROM (SELECT * FROM tcard SAMPLE(1) ORDER BY dbms_random.VALUE)
          WHERE branch = 1
                CANCELDATE > SYSDATE
                AND ROWNUM <= 100);
Advertisements
Categories: PL/SQL Tags: , ,
  1. Friday, 21 January, 2011 at 3:40 pm

    Note: dbms_random is not true random number generator, just pseudo-random.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: