Write a SQL query to find duplicate records in a table and explain how you would clean up this test data.
Treat rows as duplicates when every column except record_id matches, including matching NULL values. Identify all rows belonging to duplicate groups, then explain how to retain the lowest record_id and remove the other copies.
record_id, duplicate-defining columns, duplicate_count, and duplicate_rank.record_id ascending.| Column | Type | Description |
|---|---|---|
| record_idPK | INT | Unique identifier for the test record |
| customer_id | INT | Identifier of the customer associated with the event |
| event_type | VARCHAR(30) | Type of customer event |
| event_date | DATE | Date on which the event occurred |
| amount | NUMERIC(10,2) | Amount associated with the event |
| source | VARCHAR(20) | Originating test-data source |