Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Duplicate customer-product pairs

SQL data engineering interview problem. Difficulty: intermediate. Pattern: Deduplication. About 12 minutes. Part of the Pro drill bank.

In lb_orders, find (customer_id, product) pairs that appear more than once. Return customer_id, product, and order_count. Order by order_count descending, then customer_id, then product.

Constraints

  • Count rows, not distinct order dates.

Examples

Input: lb_orders customer_id | product | order_id C03 | Widget | 6 C03 | Widget | 7 C01 | Laptop | 1 Output: customer_id | product | order_count C03 | Widget | 2 Why this passes: Widget appears twice for C03. Laptop appears once so it is excluded by HAVING.

Topics: lakebench, sql, duplicates, having.

More SQL interview questions · All interview problems · Learn data engineering

intermediate

Duplicate customer-product pairs

Interview-style drill: Find customer_id + product combinations that appear more than once.

In `lb_orders`, find `(customer_id, product)` pairs that appear more than once. Return `customer_id`, `product`, and `order_count`. Order by `order_count` descending, then `customer_id`, then `product`.