How to Select a Random Row

I’ve seen similar questions in programming forums about how to select a random row from a table. Most RDBMS have functions to generate random numbers, so with a simple query we can select a random row(s):

The above command will sort the HR.EMPLOYEES table in random order, so we’ll be able to select a random. If you want to limit the number of returning rows, you can use subquery method:

Please share
  •  
  •  
  •  
  •  
  •  
  •  

AWS Big Data Specialist. Oracle Certified Professional (OCP) for EBS R12, Oracle 10g and 11g. Co-author of "Expert Oracle Enterprise Manager 12c" book published by Apress. Awarded as Oracle ACE (in 2011) and Oracle ACE Director (in 2016) for the continuous contributions to the Oracle users community. Founding member, and vice president of Turkish Oracle User Group (TROUG). Presented at various international conferences including Oracle Open World.

Leave Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.