I have the following:
Date Value
2015-12-28 5 //WK 53 2015
2016-01-01 10 //WK 53 2015
2016-01-04 4 //WK 1 2016
I try to group the data by iso week and get the avrage value of each week with the folloing query:
SELECT CONCAT(DATEPART(ISO_WEEK, Date),';', YEAR(Date)) AS 'Date', ROUND(AVG(Value), 2) AS 'Value'
FROM table
GROUP BY DATEPART(ISO_WEEK, Date), YEAR(Date)
The problem is that with this group by, 2016-01-01 is treated as week 53 of 2016 instead of 2015, giving me the wrong data.
Is there an easy fix to correctly group by the correct week?
Also a side question: Is it possible to display the first day of the week instead of the CONCAT I have?