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 |