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
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Gokhan Atil is a database administrator who has hands-on experience with both RDBMS and noSQL databases, and strong background on software development. He is certified as Oracle Certified Professional (OCP) and is awarded as Oracle ACE (in 2011) and Oracle ACE Director (in 2016) for his continuous contributions to the Oracle users community.

Leave Comment

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