• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1314
  • Last Modified:

selecting random records in an Oracle query

Experts,

I would like to select a certain number of random records in an Oracle query.

SELECT  *
FROM    (
        SELECT  *
        FROM    mytable
        ORDER BY
                dbms_random.value
        )
WHERE rownum <= 1000

I saw this code on the internet.  Can someone tell me what dbms_random.value is.  I
0
morinia
Asked:
morinia
1 Solution
 
Steve WalesSenior Database AdministratorCommented:
This is Oracle's built in random number generator

See docs: http://docs.oracle.com/cd/E11882_01/appdev.112/e40758/d_random.htm#ARPLS040

So it orders by a randomly generated number.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now