title: Select random row for each group
body: <p>I have a table like this</p>
  
  <pre><code>ID    ATTRIBUTE
   1    A
   1    A
   1    B
   1    C
   2    B
   2    C
   2    C
   3    A
   3    B
   3    C
  </code></pre>
  
  <p>I'd like to select <em>just one</em> random attribute for each ID. The result therefore could look like this (although this is just one of many options</p>
  
  <pre><code>ATTRIBUTE
  B
  C
  C
  </code></pre>
  
  <p>This is my attempt on this problem</p>
  
  <pre><code>SELECT
    "ATTRIBUTE"
  FROM
    (
    SELECT
      "ID",
      "ATTRIBUTE",
      row_number() OVER (PARTITION BY "ID" ORDER BY random()) rownum
    FROM
      table
    ) shuffled
  WHERE
    rownum = 1
  </code></pre>
  
  <p>however, I don't know if this is a good solution, as I need to introduce row numbers, which is a bit cumbersome.</p>
  
  <p>Do you have a better one?</p>