本周我已经算上了铭文。 但我需要在过去12周内每周计算一次铭文,并将其发送到阵列中。
我的实际要求是:
SELECT COUNT(*) FROM PERSON
YEAR(date_inscription) = YEAR(NOW())
AND WEEK(date_inscription) = WEEK(NOW())
答案 0 :(得分:5)
SELECT YEARWEEK(date_inscription) as yweek,
COUNT(*) as cnt
FROM PERSON
where YEARWEEK(date_inscription) >= YEARWEEK(curdate()) - 12
group by yweek