title: SQL Server equivalent of PostgreSQL distinct on ()
body: <p>I would like to have a Sql Server equivalent of the PostgreSQL <code>distinct on ()</code></p>
  
  <pre><code>a  b
  ----
  1  1
  1  2
  2  2
  2  1
  3  3
  
  select distinct on (a) * 
  from my_table
  
  a  b
  ----
  1  1
  2  2
  3  3
  </code></pre>
  
  <p>I could do in SQL Server:</p>
  
  <pre><code>select a, min(b) -- or max it does not matter
  from my_table
  group by a
  </code></pre>
  
  <p>But in cases where there are many columns and the query is an ad hoc one it is very tedious to do. Is there an easy way to do it?</p>