leetcode 1045 买下所有产品的客户

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
)

 

==

posted @ 2023-05-11 17:05  Carl_ZhangJH  阅读(13)  评论(0)    收藏  举报