Mysql需要每周COUNT题词持续12周
作者:互联网
本周我已经算上了铭文.
但我需要在过去12周内每周计算一次铭文,并将其发送到阵列中.
我的实际要求是:
SELECT COUNT(*) FROM PERSON
YEAR(date_inscription) = YEAR(NOW())
AND WEEK(date_inscription) = WEEK(NOW())
解决方法:
SELECT YEARWEEK(date_inscription) as yweek,
COUNT(*) as cnt
FROM PERSON
where YEARWEEK(date_inscription) >= YEARWEEK(curdate()) - 12
group by yweek
标签:mysql,date,count,week-number 来源: https://codeday.me/bug/20190620/1245109.html