title: Mysql min and max values and corresponding "date" for each month
body: <p>I have a table named "rates" and it has two fields "date" and "rate". I like to get MIN and MAX rate values and their dates on which they occurred for each month. But I could not manage.</p>
  
  <blockquote>
    <p>SELECT  date,<br>
    MIN(rate) AS minRate,<br>
    MAX(rate) AS maxRate,<br>
    MONTH(date) AS monthName,<br>
    YEAR(date) AS yearName<br>
    FROM rates<br>
    GROUP BY  yearName ASC, monthName ASC  </p>
  </blockquote>
  
  <p><strong>Clarification:</strong> I  like to get something like this:</p>
  
  <pre><code> Months  MIN    mindate     MAX      maxdate  
   Jan     1.234  2012-01-13   1.534  2012-01-24  
   Feb     1.165  2012-02-28   1.373  2012-02-11  
  </code></pre>
  
  <p>and so on</p>