# 1045. Customers Who Bought All Products [leetcode](https://leetcode.com/problems/customers-who-bought-all-products/description/) ![image](https://hackmd.io/_uploads/SkR1D0q6p.png) ![image](https://hackmd.io/_uploads/SJNgvC566.png) 這一題要我們找出擁有買完所有product的customer 所以我們先將 customer 分組 當我們分組的customer的product訂單數 = 總訂單 就是答案 ```SQL select customer_id from customer group by customer_id having count(distinct product_key ) = (select count(product_key ) from product) ```