I have a table with a date column and I would like to try and group by, using a week as a time reference in order to count how many rows occured per week. I have done this for days, using GROUP BY Date(Date_Column
) but i'm unsure how to do this by week?
Thanks
SELECT ...
FROM ....
GROUP BY YEAR(Date_column), WEEKOFYEAR(Date_Column);
Try to put a GROUP BY YEARWEEK(date_column)
at the end of your query - this will take in consideration also the year the date is in.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With