Write a query to deduplicate a dataset where multiple system events have the same timestamp but different payload details for Plangrid construction events.
Treat rows with the same project_id, event_type, and event_timestamp as duplicates. Retain the row with the latest ingested_at; break ties by the greatest event_id.
event_id, project_id, event_type, event_timestamp, payload, and ingested_at.project_id, event_timestamp, event_type, and event_id ascending.| Column | Type | Description |
|---|---|---|
| event_idPK | BIGINT | Unique identifier for the ingested event row |
| project_id | VARCHAR(30) | Plangrid construction project identifier |
| event_type | VARCHAR(50) | Type of construction system event |
| event_timestamp | TIMESTAMP | Timestamp at which the construction event occurred |
| payload | TEXT | Payload details recorded for the event |
| ingested_at | TIMESTAMP | Timestamp at which the event row entered the system |