gpt4 book ai didi

MySQL 统计购买特定商品的唯一客户

转载 作者:行者123 更新时间:2023-11-29 11:14:52 24 4
gpt4 key购买 nike

tbl_产品

+-------+---------+---------+
| id | item | Customer|
+-------+---------+---------+
| 1 | Apple | brad |
| 2 | Apple | alex |
| 3 | Apple | brad |
| 4 | Apple | brad |
| 5 | Apple | tim |
| 6 | Orange | brad |
| 7 | Orange | steve |
| 8 | Orange | alex |
+-------+---------+---------+

有多少独立客户购买了 Apple?答案应该是:苹果3

最佳答案

试试这个:

SELECT COUNT(DISTINCT Customer)
FROM tbl_products
WHERE item ='Apple'

关于MySQL 统计购买特定商品的唯一客户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39917501/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com