mySQL-如何查看上个月而不是本月哪些用户提交了订单?

问题描述

我需要弄清楚上个月而不是本月提交订单的用户。这是我当前要计算的总用户数查询,但是如何查看本月的购买者而不是最近一个月的购买者?

SELECT DISTINCT(customer_user_id)
FROM customer_orders 
WHERE created_on > '2020-07-01'

这是我的客户订单表

enter image description here

这将是预期的输出,所有用户的列表

this would be the expected output,a list of all the users

编辑:此外,我正在尝试获取7月而非8月提交订单的用户的报告,其中包括当月的总金额,订单数量和用户手机号码。这是我正在使用的查询,但没有给我结果。


SELECT DISTINCT(co.customer_user_id),SUM(co.amount),COUNT(co.order_id),s.cellphone
FROM customer_orders co
JOIN subscribers s
ON co.customer_user_id = s.user_id
WHERE co.created_on > '2020-07-01'
AND month(co.created_on) <> month(curdate());

这是我的订户表,上面是我的客户订单表。

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)