【发布时间】:2017-03-19 22:05:55
【问题描述】:
我想创建一个变量来计算每个客户 ID 在 CSV 中出现的次数,然后我希望输出是出现 0、1 或 2 次的所有客户 ID。到目前为止,这是我的代码:
SELECT Customers.customer_id , COUNT(*) AS counting
FROM Customers
LEFT JOIN Shopping_cart ON Customers.customer_id = Shopping_cart.customer_id
WHERE counting = '0'
OR counting = '1'
OR counting = '2'
GROUP BY Customers.customer_id;
【问题讨论】:
-
请为您正在使用的数据库添加标签,例如SQL Server 2016,MySQL。
-
我目前不明白这个问题。您想要出现 0 到 2 次的所有客户 ID?
-
如果某个答案对您有帮助,请将其标记为答案......