Challenge: Finding Customers Who Bought Everything
Difficulty: Medium
Data:
Two tables store information about customer purchases:
Customer (Primary Key: customer_id):
customer_id (int): Unique identifier for a customer.
product_key (int): Foreign key referencing the Product table (product purchased).
Product (Primary Key: product_key):
product_key (int): Unique identifier for a product.
Objective:
Identify customer IDs from the Customer table who have purchased all products listed in the Product table.
Output:
A table with a single column:
customer_id (int): Unique identifier for a customer who bought all products (same as input table).
Explanation:
We need to find customer_id values in the Customer table where the distinct count of product_key matches the total number of unique products in the Product table. This indicates customers who purchased every product.
SQL MYSQL leetcode Solution with HAVING and DISTINCT COUNT
Смотрите видео Customers Who Bought All Products SQL MySQL leetcode Solution using having онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал CodeWis Technologies by Nuhman Paramban 20 Май 2024. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 113 раз и оно понравилось 0 посетителям.