仅对于拥有100个以上顾客的包裹,显示包裹号和每个包裹号的顾客数量。
SELECT pack_num, COUNT(customer)
FROM table_name
GROUP BY pack_num
HAVING COUNT(customer) >100
此查询正确吗?如果没有,请纠正我。
答案 0 :(得分:0)
要仅计算独特的客户,您可以添加DISTINCT to the COUNT。
My-iMac:TIS my$ mssql -u tisApp -p pasSw0rd
Connecting to localhost...done
sql-cli version 0.6.2
Enter ".help" for usage hints.
mssql>