Your question is Latest Row Per Group. Start with the requirements and the one table on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
A Fivetran connector audit pipeline stores multiple sync records for the same source record. Write a PostgreSQL query that identifies duplicate groups and returns only the most recently synced row from each group.
connector_id, source_table, and record_key.synced_at, using id as a deterministic tie-breaker.| Column | Type | Description |
|---|---|---|
| idPK | INTEGER | Unique sync record identifier |
| connector_id | INTEGER | Fivetran connector identifier |
| source_table | VARCHAR(100) | Source table captured by the connector |
| record_key | VARCHAR(100) | Source record key used to define a duplicate group |
| payload_hash | VARCHAR(64) | Hash of the captured record payload |
| synced_at | TIMESTAMPTZ | Timestamp when the record was synced |