title: using min, max and avg in mysql query
body: <p>I have a table Like below.</p>
  
  <p>I want the product_id of Minimum, Maximum and Average cost products in a single query.</p>
  
  <pre><code>CREATE TABLE productlist(product_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
                           cost INT);                             
  
  INSERT INTO productlist(cost)
                   VALUES('2450'),
                         ('2200'),
                         ('2580'),
                         ('2405'),
                         ('3500'),
                         ('1500'),
                         ('1800'),
                         ('1520'),
                         ('1740'),
                         ('1940'),
                         ('2940'),
                         ('1250'),
                         ('1290'),
                         ('1390'),
                         ('2900');
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>Min    12
  Max    5
  Avg    2093
  </code></pre>
  
  <p>I tried like one below but its not working.</p>
  
  <pre><code>SELECT product_id, MIN(cost) as mincost
    FROM productlist
   GROUP BY product_id
   ORDER BY mincost ASC
   LIMIT 0,1
   UNION
  SELECT product_id, max(cost) as maxcost
    FROM productlist
   GROUP BY product_id
   ORDER BY maxcost DESC
   LIMIT 0,1
  </code></pre>
  
  <p>How should I do this</p>