How would you write a query to identify and remove duplicate records from a transactional table?
Assume records are duplicates when they share the same transaction reference, account, date, amount, and status. Retain the record with the smallest transaction ID and remove later copies.
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INTEGER | Unique identifier for the stored transaction record |
| transaction_ref | VARCHAR(30) | Source transaction reference |
| account_id | INTEGER | Account associated with the transaction |
| transaction_date | DATE | Business date of the transaction |
| amount | NUMERIC(12,2) | Transaction amount |
| status | VARCHAR(20) | Processing status |
| created_at | TIMESTAMP | Timestamp when the record entered the table |