title: postgresql query to delete duplicate entries in a table
body: <p>I have a table as :</p>
  
  <pre><code>id   product id  merchant id    price      upc
  1    124          2            2000000    1234XDE
  2    124          2            200000     1234XDE
  3    124          2            200000     1234XDE
  4    124          2            200000     1234XDE
  5    124          2            200000     ASDER36
  6    134          1            300        ASERT56
  7    134          2            300        ASERT56
  </code></pre>
  
  <p>I want to delete all the multiple entries from the table. </p>
  
  <pre><code>Delete from 
  table where id not in (Select min(id) from table group by(merchant id))
  </code></pre>
  
  <p>but no success. I want resulting table as:</p>
  
  <pre><code>id   product id   merchant id   price    upc
  1    124           2            2000000   1234XDE
  5    124           2            2000000   ASDER36
  6    134           1            300       ASERT56
  7    134           2            300       ASERT56
  </code></pre>
  
  <p>Can someone help me in writing a query for this.</p>