title: How to return MAX and MIN of a value from a table?
body: <p>I want to get the last cost with latest costing date and minimum cost for products.</p>
  
  <p>When I use the query below, it is giving me the Max Date and Min Cost for each column. Please see the screenshots below.</p>
  
  <pre><code>SELECT MAX(CostingDate) AS LatestDate,
  MIN(Cost) AS MinPrice,
  OutletCode,
  ProductID  
  FROM AccountsCosting
  WHERE OutletCode = 'C&amp;T01'
  GROUP BY OutletCode, ProductID
  </code></pre>
  
  <p>Result: </p>
  
  <p><img src="https://i.stack.imgur.com/ofv2v.png" alt="enter image description here"></p>
  
  <p>E.g - for productID: <code>200006</code></p>
  
  <pre><code>SELECT * FROM AccountsCosting
  WHERE ProductID = 200006 AND OutletCode = 'C&amp;T01'
  ORDER BY CostingDate DESC
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/DRD4T.png" alt="enter image description here"></p>
  
  <p>What I want is the last costing date with the minimum cost (the one that I highlighted with red color). Even if the purchase date is the same <code>2013-03-20</code>, it should return the minimum cost.</p>
  
  <p><img src="https://i.stack.imgur.com/i1u0g.png" alt="enter image description here"></p>
  
  <p>How can I edit my query to get the result? Any help will be much appreciated!</p>