title: How to select only 1 row per unique field (with another field determining which in case of duplicates)
body: <p>I've looked around for a while, and I'm not really sure whether I need some sort of IF statement, LIMIT statement, or something completely different.</p>
  
  <p><strong>SITUATION</strong></p>
  
  <p>I have a database that looks something like this:</p>
  
  <pre><code>id    |   elem_id   |  elem_data  | draft
  1     |  uniq1234   |  examplestr |   0
  2     |  uniq1653   |  examplestr |   1
  3     |  uniq9964   |  examplestr |   0
  4     |  uniq1234   |  examplestr |   1
  </code></pre>
  
  <p>And so on and so forth...</p>
  
  <p><strong>My Intent</strong></p>
  
  <p>I want to select only one row for every unique <code>elem_id</code>. Where two exist, I want to select the one that has a draft value of 1. (So, for a query on the above table it would find two occurrences of the elem_id <code>uniq1234</code> and select the one with the draft value of 1 (that is, row 4)).</p>