Simple solution with Common Table Expressions | Beats 90.23% Runtime | Beats 100% Memory |
Intuition\nSimple solution by aggregating on the sum & count of the product ids\n\n# Approach\nUse of common table expression (CTE) to access information from t
# Intuition\nSimple solution by aggregating on the sum & count of the product ids\n\n# Approach\nUse of common table expression (CTE) to access information from the Product table without having the need to join, as joining would not yield any valuable results\n\n\n# Code\n```\nwith sample as \n(select sum(product_key) from Product),\n\nsample1 as\n(select count(product_key) from Product)\n\nselect customer_id from Customer\ngroup by customer_id\nhaving sum(distinct product_key) = (select * from sample) and count(distinct product_key) = (select * from sample1);\n```
[]