Find Duplicate Orders

medium
Unit 22 · Joins0/2 to milestone

A payment retry bug created duplicate orders: same customer, same date, same total. Find each group of duplicates and return customer_id, order_date, total, copies (how many rows are in the group) and keep_id (the lowest order id, the one to keep). Only include groups with more than one row. Sort by customer_id, then order_date.

The shop data has no duplicates, so test against your own rows too.

Schema

customers(id, name, country, signup_date)
orders(id, customer_id, order_date, total)
#group-by#having#data-quality2 visible + 1 hidden tests
query.sql · SQLite
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Find Duplicate Orders · TechGradify