I'm developing a logger for my photovoltaic panels, and I've a mysql table with the daily production of last 5 years. I'd like to extract and aggregate the monthly production as for example:
jan 2010= x kWh
jan 2011= ...
jan 2012=...
jan 2013=...
and so on.. Is there a quick way to accomplish that in mysql-php, without make too much different selects? Thank you in advance...
If your table has a date field, in which you store daily production you can use a group by on this field, this should work :
select DATE_FORMAT(date, "%M-%Y") as monthyear, sum(production)
from production
group by monthyear
order by monthyear