How to get count (last 4 weeks records and week range) group by week range?
Week range means 22-28, 15-21,8-14, 1-7
I tried this
SELECT WEEK(PERIOD), SUM(CLICKS)
FROM TABLE
WHERE PERIOD >= NOW() - INTERVAL 4 WEEK
GROUP BY WEEK(PERIOD)
and
SELECT WEEKOFYEAR(`date`) AS period,
SUM(clicks) AS clicks
FROM `tablename`
WHERE `date` >= CURDATE() - INTERVAL 4 WEEK
GROUP BY period
If you mean last 4 weeks by exactly each 7 x 24 days prior to today, up to the second, then