Write a SQL query to identify duplicate policy records within a database and retain only the most recently updated entry.
Treat records with the same policy_number as duplicates. If update timestamps are tied, retain the record with the greatest policy_id. Do not include older duplicate records.
policy_id, policy_number, policyholder_name, policy_status, premium_amount, and updated_at.policy_number ascending.| Column | Type | Description |
|---|---|---|
| policy_idPK | INTEGER | Unique identifier for a policy record version |
| policy_number | VARCHAR(30) | Business identifier used to detect duplicate policy records |
| policyholder_name | VARCHAR(100) | Name of the policyholder |
| policy_status | VARCHAR(20) | Current status recorded for the policy version |
| premium_amount | NUMERIC(12,2) | Policy premium amount |
| updated_at | TIMESTAMP | Timestamp when the policy record was last updated |