Deduplicate a dataset where duplicate records exist with minor variations in timestamps, keeping only the most recent entry per unique user ID on Snowflake.
Write a PostgreSQL-compatible SQL query against the provided table. Exclude records without a user ID and use event_id as the deterministic tie-breaker when timestamps are equal.
user_id, event_id, event_type, event_timestamp, and source.user_id ascending.| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique identifier for the activity record |
| user_id | INT | Identifier of the user associated with the activity |
| event_type | VARCHAR(50) | Type of activity recorded |
| event_timestamp | TIMESTAMP | Timestamp when the activity occurred |
| source | VARCHAR(50) | System or channel that produced the record |