Data Analyst/daily
[코트카타 105]
rubus0304
2024. 12. 18. 10:06
Customers Who Bought All Products
(오답) 5,6 product_key를 다 산 customer_id ㅠㅠ 왜 안 나오지.
select customer_id
from customer_id in (select c.customer_id
from customer c join product_key p on c.product_key = p.product_key
where p.product_key = 5 or 6) a
(정답)
select customer_id
from customer
group by 1
having count(distinct product_key) = (select count(*) from product)
product_key 에 distinct 를 해야했다. 그리고 이어져야하니까 select count(*)랑 같아야함.