sql查询订购超过15次的客户

时间:2019-05-31 06:00:24

标签: mysql

如何获取订购超过15次的客户列表。 我有customerId,orderId,orderValue,orderDate。

我尝试了

select *  from customertable Group By customerId having count (*) > 15

2 个答案:

答案 0 :(得分:2)

您可以在下面尝试-

select customerid
  from customertable 
  Group By customerId having count (distinct orderid) >= 15

答案 1 :(得分:0)

SELECT customerid, COUNT(*) counter
FROM customertable 
GROUP BY customerId HAVING counter >= 15