标签:rod and 销售 tco _id select write etc statement
编写一个 SQL 查询,查询购买了 S8 手机却没有购买 iPhone 的买家。
使用having + sum+if,而不是自查询。
# Write your MySQL query statement below
select buyer_id
from Sales s join Product p
on s.product_id = p.product_id
group by buyer_id
having sum(if(product_name=‘S8‘,1,0))>0
and sum(if(product_name=‘iPhone‘,1,0))=0
[LeetCode]1083. 销售分析 II(Mysql,having+if)
标签:rod and 销售 tco _id select write etc statement
原文地址:https://www.cnblogs.com/coding-gaga/p/13040949.html