i want to group my data by yearweek but the week starts here in sunday.
how can i group my week from monday till sunday?
Here is my query:
SELECT YEARWEEK(dateStats) k,dateStats udate, COUNT(f_shop) sales
FROM sal_import WHERE dateStats BETWEEN "2011-08-15" AND "2011-08-21" GROUP BY YEARWEEK(dateStats)
The Between has a date from Monday till Sunday and i need just one row at the result.
Thank you very much
解决方案
Second argument of YEARWEEK(date[,mode]) function is mode - like in WEEK(date[,mode]) function.
You can specify start day - default is 0 (Sunday).
Just set it to 1 (Monday):
YEARWEEK(dateStats, 1)