Easy Solution🔥|| MySQL || Having Clause || 100% Fast✅
Intuition \uD83E\uDDE0\n Describe your first thoughts on how to solve this problem. \nWe have to count the distinct product keys for each customers and then che
# Intuition \uD83E\uDDE0\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe have to count the distinct product keys for each customers and then check if it matches with all the types of products in the product table.\n# Approach \uD83D\uDEE4\uFE0F\n<!-- Describe your approach to solving the problem. -->\nTo check that the count of distinct product keys of a customer is equal to the total types of products in Products table. We will just check if the count distinct of product key in Customer table is equal to count of Product Key in Products Table. So for that we have to add the condition in having clause.\n\n# Code \uD83E\uDDD1\u200D\uD83D\uDCBB\n```\nselect customer_id\nfrom Customer\ngroup by customer_id\nhaving count(distinct product_key) = (select count(product_key) from Product)\n```\n\n![image.png](https://assets.leetcode.com/users/images/d72c738f-2795-4c86-9fad-3e746bf42661_1691419489.5374012.png)\n
['Database', 'MySQL']