I have two columns "date" and "temperature". I want to select average temperature between two specific dates e.g. 1 - 7 April grouped by year. When i use this query
select avg(temperature) from table where dayofyear(date) between 91 and 97 group by year(date)
two problems appear.
- In leap years dayofyear for days after 28 February has different value
- When I want select average from e.g. between 30 December and 5 January this query:
select avg(temperature) from table where dayofyear(date) between 364 and 5 group by year(date)returns 'null'.
In coresponding to point 2 is another problem. How to receive data between e.g. 30 December (a year before) and 5 January grouped by year?