[英]Select all customer who have bought 'x' times something from the category 'y' within the last 'z' days
I have difficulties with the following statement: 我对以下陈述感到困难:
Select all customer who have bought 'x' times something from the category 'y' within the last 'z' days. 选择最近“ z”天内从“ y”类别中购买了“ x”次商品的所有客户。
The table contains 3 columns. 该表包含3列。 1. email address 2. category 3. timestamp
1.电子邮件地址2.类别3.时间戳
Any help would be much appreciated! 任何帮助将非常感激!
Thanks a lot! 非常感谢!
You can use below query for your criteria 您可以使用以下查询作为您的条件
SELECT category ,email,COUNT(*) purchases
FROM table
WHERE category = 'y'
AND `timestamp` >= TIMESTAMP(CURDATE() - INTERVAL z DAY)
GROUP BY email
HAVING purchases = 'x'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.