These is a database which is formatted like this.
Date Count
'2001-03-04' 4
'2001-03-05' 5
'2001-03-06' 4
'2001-03-08' 1
'2001-03-09' 3
This database goes on for 15 years or so. I need to display a rolling 12 month graph displaying counts and month. How would I find the sum of each month in a 12 month period.
iv tried that
$sql_months = "SELECT date(D.`created`) 'Date', count(*) 'Count'
FROM mytable
group by date(D.`created`)
where D.`created` >= DATEADD(month, -12, GETDATE())";
$result_months = $conn->query($sql_months);
How would I achieve this with php or sql code.
month count 8 12 11 06
etc for each month, 12 months backward from the current month.