Wednesday, June 20th, 2007...1:45 pm

Randomizing Query Results in Oracle

Jump to Comments

I was doing some work this afternoon, and I needed some sample id's from a database query, however all the data ended up being related to the same person because of the ordering of the results. There must be a better way, i want random results in my resultset.

Here's how (in oracle), order by a random value using dbms_random.value()

SELECT * FROM OURTABLE ORDER BY dbms_random.value()

Leave a Reply