I am currently using the query below to collect a total of the ER_read table in between 2 dates. This works fine but I need to split these results into weekly segments e.g. the first week of october = 40 (i think). Is there a function in MsSQL or PHP to do this, and how would I use it?
SELECT SUM(ER_read) as total
FROM tblEread
WHERE ER_ID='$sensor'
AND MONTH(ER_date) >= '$firstMonth'
AND MONTH(ER_date) <= '$lastMonth'
AND YEAR(ER_date) = '$year'
GROUP BY ER_ID;
Thanks for any help