Write a SQL query to find and remove duplicate records from a database table.
Treat rows as duplicates when policy_number, effective_date, risk_score, and source_system are identical, including matching NULL values. Retain the row with the smallest record_id in each duplicate set and return the records removed.
record_id, policy_number, effective_date, risk_score, and source_system.record_id in ascending order.| Column | Type | Description |
|---|---|---|
| record_idPK | INT | Unique identifier for the risk record |
| policy_number | VARCHAR(30) | Policy identifier supplied by the source system |
| effective_date | DATE | Date on which the policy risk record becomes effective |
| risk_score | INT | Calculated risk score |
| source_system | VARCHAR(30) | System that supplied the record |