Your question is SQL Query to Remove Duplicate Rows. Start with the requirements and the one table on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Write a query to identify and remove duplicate rows from a high-volume table.
Use payment_transactions. Treat payment_id as the unique row identifier and all other columns as the duplicate-detection fields. Retain the row with the smallest payment_id in each duplicate set.
payment_idpayment_id ascending| Column | Type | Description |
|---|---|---|
| payment_idPK | INTEGER | Unique payment transaction identifier |
| merchant_id | VARCHAR(30) | Merchant identifier |
| customer_id | VARCHAR(30) | Customer identifier, when available |
| amount | NUMERIC(12,2) | Payment amount |
| currency | VARCHAR(3) | ISO currency code |
| payment_status | VARCHAR(40) | Current payment processing status |
| paid_at | TIMESTAMP | Payment completion timestamp |