title: Postgresql Distinct on Order By
body: <p>I have data that looks like the table below. </p>
  
  <pre><code>   date       value symbol  time        id
  0 2014-01-01      0      A 2014-01-01   65
  1 2014-01-02      1      B 2014-01-02   66
  2 2014-01-03      2      A 2014-01-03   65
  3 2014-01-04      3      B 2014-01-04   66
  4 2014-01-05      5      A 2014-01-05   65
  5 2014-01-05      4      A 2014-01-05   65
  6 2014-01-06      6      B 2014-01-06   66
  </code></pre>
  
  <p>I'm trying to write an expression that will do a sort on <code>symbol</code> and <code>value</code>, and then a distinct on <code>date</code> and <code>id</code>. From what I understand, this isn't possible, since the distinct on needs to match what I order by.</p>
  
  <p>What I want is to get the above table, but without row 4, since it will sort on <code>symbol</code> and <code>value</code> ascending, and then distinct and choose the first row in that sorted table. Is there a way to achieve this?</p>