title: How to retrieve random records from Oracle with dbms_random
body: <p>I am a beginner in sql and I was wondering if you could help me figure out how to retrieve random records from Oracle. I have the following query:</p>
  
  <pre><code>SELECT p.* from data p where p.id in 
  (SELECT DISTINCT t.id   FROM DATA t, comment c, PTV ptv   
  WHERE t.code not in ('x','y','Z') 
  and t.id = c.id(+)   and ptv.code = t.code   and ptv.code = t.code   
  and ptv.version = t.version  AND t.TASK_CODE != 'DRAFT')
  </code></pre>
  
  <p>How can i select X number of random records from the results returned by the above query? Any suggestions will be appreciated.</p>