title: Sql query to find cheapest product from given data
body: <p>I have data in following format</p>
  
  <pre><code>Id,Vendor,Product Name,Product Code,Unit,Weight,Price
  
  1,Vendor1,Coriander Leaves (April-Nov),3736,Kg,3,90
  
  2,Vendor1,Mint Leaves 500 Gm,4371,Grams,500,27.5
  
  3,Vendor1,Ginger 500 Gm,4356,Grams,500,29.5
  
  4,Vendor1,Lemon 500 Gm,4365,Grams,500,32.5
  
  5,Vendor2,Coriander Leaves (April-Nov),3736,Kg,3,80
  
  6,Vendor2,Mint Leaves 500 Gm,4371,Grams,500,27.5
  
  7,Vendor2,Ginger 500 Gm,4356,Grams,500,30
  
  8,Vendor2,Lemon 500 Gm,4365,Grams,500,31
  
  9,Vendor3,Coriander Leaves (April-Nov),3736,Kg,3,88
  
  10,Vendor3,Mint Leaves 500 Gm,4371,Grams,500,27.3
  
  11,Vendor3,Ginger 500 Gm,4356,Grams,500,29.7
  
  12,Vendor3,Lemon 500 Gm,4365,Grams,500,34.5
  </code></pre>
  
  <p>I want to generate a product list based on:</p>
  
  <ul>
  <li><p>cheapest prices</p></li>
  <li><p>expensive prices</p></li>
  </ul>
  
  <p>For example, for cheapest prices, we would get a list like:</p>
  
  <p>3,Vendor1,Ginger 500 Gm,4356,Grams,500,29.5</p>
  
  <p>5,Vendor2,Coriander Leaves (April-Nov),3736,Kg,3,80</p>
  
  <p>8,Vendor2,Lemon 500 Gm,4365,Grams,500,31</p>
  
  <p>10,Vendor3,Mint Leaves 500 Gm,4371,Grams,500,27.3</p>
  
  <p>I ran following query for cheapest prices</p>
  
  <pre><code>SELECT ID,DISTINCT VENDOR,productname,productcode,unit,weight,min(price) 
  from vendor_price_list 
  group by productcode;
  </code></pre>
  
  <p>but getting error:-</p>
  
  <blockquote>
    <p>ERROR 1064 (42000): You have an error in your SQL syntax; check the
    manual that corresponds to your MySQL server version for the right
    syntax to use near 'DISTINCT
    VENDOR,productname,productcode,unit,weight,min(price) from
    vendor_price' at line 1</p>
  </blockquote>
  
  <p>Any help would be appreciated.</p>