leetcode 1045 买下所有产品的客户

Carl_ZhangJH / 2023-05-11 / 原文

leetcode 1045 买下所有产品的客户

select customer_id from Customer c left join Product p
on c.product_key  = p.product_key
group by customer_id
having count(distinct c.product_key) = (select count(*) from Product)

 

select customer_id
from (
    select distinct customer_id, product_key
    from customer
) t
group by customer_id
having count(*) = (
    select count(product_key)
    from product
)

 

==