Question

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.

SELECT date,
MIN(rate) AS minRate,
MAX(rate) AS maxRate,
MONTH(date) AS monthName,
YEAR(date) AS yearName
FROM rates
GROUP BY yearName ASC, monthName ASC

Clarification: I like to get something like this:

 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  

and so on

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top