Supercloud Customer

ASKED IN INTERVIEW
4pts
Microsoft

Problem Statement

Microsoft Azure wants to identify its Supercloud customers. A Supercloud customer is defined as a customer who has purchased at least one product from every single product category offered.

Write an SQL query to find the customer_id of these Supercloud customers.

Rules:

  • You must account for all categories present in the categories table.
  • A customer must have at least one purchase record associated with every category_id.
  • Output a single column: customer_id.
  • Results must be sorted by customer_id in ascending order.
Tests your understanding of
Relational Division, Aggregation, JOIN and Filtering

Input Tables

categories
category_id(INTEGER)category_name(VARCHAR)
1Compute
2Storage
3Analytics
products
product_id(INTEGER)product_name(VARCHAR)category_id(INTEGER)
101Azure VM1
102Blob Storage2
103Data Factory3
104Functions1
customer_purchases
customer_id(INTEGER)product_id(INTEGER)
1101
1102
1103
2101
2102
3101
3102
3103
3104
4103

Expected Output

customer_id(INTEGER)
1
3

Tags

MediumASKED IN INTERVIEWRelational DivisionAggregationJOINFiltering
20-25 min
46%

Hints