给定一个包含客户和产品的简单表格(订单详细信息/历史记录之类的东西):
+--------------------+
| customer | product |
+--------------------+
| Smith | p1 |
| Smith | p3 |
| Jones | p1 |
| Jones | p2 |
| Davis | p3 |
| Davis | p9 |
| Brown | p1 |
| Brown | p2 |
| Brown | p5 |
+----------+---------+
我想列出所有从未订购过产品p1的客户,即上述数据集中的Davis。
这是我开始的地方,但当然,它不起作用,我想不出下一步该去哪里:
select
customer,
count(*) as c
where product='p1'
and c = 0