1045. 買下所有產品的客戶 難度:中等

1、題目描述

在這裏插入圖片描述
在這裏插入圖片描述
來源:力扣(LeetCode)

2、解題思路

1# 首先對Customer去重,select distinct * from customer
2# 然後,統計每個客人購買的貨物種類數量select customer_id,count(product_key) cou1
3# 增加子表,對Product統計所有貨物種類select count(*) as cou2 from Product
4# 對比兩個量

3、提交記錄

select customer_id
from

(select customer_id,count(product_key) cou1
from (select distinct * from customer)a3
group by customer_id) a,

(select count(*) as cou2
from Product)b
    
where a.cou1=b.cou2
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章