title: Oracle aggregate function to return a random value for a group?
body: <p>The standard SQL aggregate function <code>max()</code> will return the highest value in a group; <code>min()</code> will return the lowest.</p>
  
  <p>Is there an aggregate function in Oracle to return a random value from a group? Or some technique to achieve this?</p>
  
  <p>E.g., given the table <code>foo</code>:</p>
  
  <pre><code>group_id value
  1        1
  1        5
  1        9
  2        2
  2        4
  2        8
  </code></pre>
  
  <p>The SQL query</p>
  
  <pre><code>select group_id, max(value), min(value), some_aggregate_random_func(value)
  from foo
  group by group_id;
  </code></pre>
  
  <p>might produce:</p>
  
  <pre><code>group_id  max(value), min(value), some_aggregate_random_func(value)
  1        9            1           1
  2        8            2           4
  </code></pre>
  
  <p>with, obviously, the last column being any random value <em>in that group</em>.</p>