Loading...
Deduplicated Sales Volume by Category
A medium SQL interview practice problem on DataDriven. Write and execute real sql code with instant grading.
- Domain
- SQL
- Difficulty
- medium
- Seniority
- senior
Problem
The transactions table contains duplicate records. First deduplicate by keeping only the first occurrence of each transaction (the one with the lowest transaction_id when multiple rows share the same user_id, product_id, total_amount, and transaction_date). Then combine with the products table and compute the total sales amount per product category, only counting transactions where total_amount is positive.
Practice This Problem
Solve this SQL problem with real code execution. DataDriven runs your SQL queries against a live PostgreSQL database and grades it instantly.