title: Efficiently selecting random duplicate entries in Oracle SQL
body: <p>I have a dataset which looks like this</p>
  
  <pre><code>   id   date
    250  01-JAN-15
    250  01-MAR-15
    360  01-JUN-15
    470  01-FEB-15
    470  01-DEC-15
    470  01-NOV-15
    780  01-APR-15
    790  01-SEP-15
    790  01-MAY-15
  </code></pre>
  
  <p>I want to <strong>randomly</strong> select rows such that duplicated <code>id</code>s will appear only once. For example:</p>
  
  <pre><code>   id   date
    250  01-MAR-15
    360  01-JUN-15
    470  01-FEB-15
    780  01-APR-15
    790  01-SEP-15
  </code></pre>
  
  <p>My current solution uses an analytic function, which takes a long time to run on hundreds of millions of rows:</p>
  
  <pre><code>select * from(
   select aa.*, row_number() over (partition by id order by dbms_random.value) as random_flag 
   from table aa)
  where random_flag = 1
  </code></pre>
  
  <p>Any tips on how to get the same result without analytic functions? </p>