我正在尝试为用户注册制作每周统计数据.它应该每周工作.一周总共七天.我想在屏幕上打印一周中每天注册的用户数.
例如:
Number of users who registered on Monday = 38
Number of users who registered on Tuesday = 11
…. …. and this list will only list the week we were
SELECT WEEKDAY(registerTime)+1, count(*)
FROM users group by WEEKDAY(registerTime)
ORDER BY WEEKDAY(registerTime)
但这个问题的结果却截然不同.此总数显示每周一在星期一注册的用户数.
解决方法:
SELECT WEEKDAY(registerTime)+1, count(*)
FROM users
WHERE WEEKOFYEAR(registerTime) = WEEKOFYEAR(CURDATE())
AND YEAR(registerTime) = YEAR(CURDATE())
group by WEEKDAY(registerTime)
ORDER BY WEEKDAY(registerTime);
基本上,您将一年中的一年和一周与您需要的相匹配.那应该够了.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。