title: How to choose minimum value row in Group By sql
body: <p>Here's a closely resembling sqlite database that I'm working with -</p>
  
  <pre><code>CREATE TABLE sampleData(
     pincode INTEGER NOT NULL,
     place_id INTEGER NOT NULL,
     price INTEGER NOT NULL,
     name TEXT NOT NULL,
     UNIQUE(pincode, place_id)
  );
  </code></pre>
  
  <p>I was looking to find names of places in every pincode(only 1 place per pincode) which has the lowest price there. The simplest query I could come up with -</p>
  
  <pre><code>SELECT * FROM sampleData 
  WHERE price &gt; 0
  GROUP BY pincode
  ORDER BY PRICE
  </code></pre>
  
  <p>which seems to work in sqlite(?) but fails to work in pg9.6 and gives wrong result in Mysql. Here's another one which seems to give same result -</p>
  
  <pre><code>SELECT * FROM sampleData 
  WHERE price &gt; 0
  GROUP BY pincode
  HAVING MIN(PRICE)
  </code></pre>
  
  <p>which has similar results as last one. I was wondering what's wrong with these queries and would love some help crafting the correct one.</p>
  
  <p><a href="http://sqlfiddle.com/#!5/d8705/2" rel="nofollow noreferrer">SQLFIDDLE</a> </p>