gpt4 book ai didi

mysql - 如何计算特定月份每天的订阅数量

转载 作者:行者123 更新时间:2023-11-29 03:17:45 25 4
gpt4 key购买 nike

(使用MySQL)我需要找出特定月份每天有多少人订阅。到目前为止,这是我的查询:

SELECT COUNT(user_ID) AS Subs,  DATE(subscription_date) AS Day_Joined FROM Users GROUP BY DAY(Day_Joined), user_ID HAVING MONTH(Day_Joined) = 03 ORDER BY Day_Joined

我希望输出给我:

subs Day_Joined
- 10 2018-03-04
- 20 2018-03-05
- 30 2018-03-06

到目前为止它给我:

subs Day_Joined
- 5 2018-03-04
- 3 2018-03-04
- 2 2018-03-04
... and so on..

最佳答案

你应该只为 Day_Joined 分组

  SELECT COUNT(user_ID) AS Subs
, DATE(subscription_date) AS Day_Joined
FROM Users
GROUP BY DATE(subscription_date)
HAVING MONTH(DATE(subscription_date)) = 03
ORDER BY

如果你也为 user_id 分组,你没有不同 user_id 的计数..

关于mysql - 如何计算特定月份每天的订阅数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52154465/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com