SQL: Identifying Customers Purchasing All Products
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: $$O(C * logC)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nSubquery: This part calculates the total number of unique products. The time complexity is O(1).\n\nMain Query: The GROUP BY operation groups customer records, which typically takes O(Clog\u2061C) time, where C is the number of rows in the Customer table.\n\n\n- Space complexity: $$O(C)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n# Write your MySQL query statement below\nSELECT\n  customer_id\nFROM\n  Customer\nGROUP BY\n  customer_id\nHAVING\n  COUNT(DISTINCT product_key) = (\n    SELECT\n      COUNT(product_key)\n    FROM\n      Product\n  );\n```\n![upvote_leetcode.png](https://assets.leetcode.com/users/images/9769bcc5-dd45-4794-9291-b8d0bcd32d66_1702915660.8288038.png)\n
['MySQL']