Zomato’s data quality team wants to identify repeated order-item records that may have been ingested more than once. Treat rows as repeated when all business columns match, excluding the unique order_item_id.
Write a PostgreSQL query to find these repeated rows and enrich the results with the restaurant name.
order_item_id values as a comma-separated list, ordered numerically.restaurant_id, restaurant_name, customer_id, item_name, quantity, unit_price, ordered_at, duplicate_count, duplicate_item_ids.duplicate_count and the aggregated ID column duplicate_item_ids.duplicate_item_ids with , , including one space after each comma.restaurant_id, then item_name, then customer_id, placing NULL customer_id values last.| Column | Type | Description |
|---|---|---|
| order_item_idPK | INT | Unique order-item record ID |
| restaurant_id | INT | References restaurants.restaurant_id |
| customer_id | INT | Customer identifier |
| item_name | VARCHAR(100) | Ordered menu item |
| quantity | INT | Quantity ordered |
| unit_price | DECIMAL(10,2) | Price per item |
| ordered_at | TIMESTAMP | Order creation timestamp |
| Column | Type | Description |
|---|---|---|
| restaurant_idPK | INT | Unique restaurant identifier |
| restaurant_name | VARCHAR(150) | Restaurant display name |