title: How to select 1 row per id?
body: <p>I'm working with a table that has multiple rows for each order id (e.g. variations in spelling for addresses and different last_updated dates), that in theory shouldn't be there (not my doing). I want to select just 1 row for each id and so far I figured I can do that using partitioning like so:</p>
  <pre><code>SELECT dp.order_id, 
         MAX(cr.updated_at) OVER(PARTITION BY dp.order_id) AS updated_at
  </code></pre>
  <p>but I have seen other queries which only use MAX and list every other column like so</p>
  <pre><code>SELECT dp.order_id, 
         MAX(dp.ship_address) as address, 
         MAX(cr.updated_at) as updated_at
  </code></pre>
  <p>etc...</p>
  <p>this solution looks more neat but I can't get it to work (still returns multiple rows per single order_id). What am I doing wrong?</p>