Write a SQL query to identify and remove duplicate records from a staging table without dropping the table.
Treat rows as duplicates when source_system, subscriber_id, event_type, event_timestamp, and payload match, including matching NULL values. Retain the row with the smallest staging_id for each duplicate set.
staging_id, source_system, subscriber_id, event_type, event_timestamp, and payload.staging_id ascending.| Column | Type | Description |
|---|---|---|
| staging_idPK | INT | Unique identifier for the staging row |
| source_system | VARCHAR(50) | System that produced the record |
| subscriber_id | VARCHAR(30) | Subscriber identifier from the source system |
| event_type | VARCHAR(40) | Type of subscriber or network event |
| event_timestamp | TIMESTAMP | Timestamp supplied by the source system |
| payload | TEXT | Raw event payload |