This website uses cookies to ensure you get the best experience.
Learn more.
A customer staging table has multiple records per customer_id. Each has an updated_at timestamp and a unique ingestion_id. Keep the latest timestamp, breaking ties with the highest ingestion_id. Which approach is deterministic?
Published
- Use ROW_NUMBER() ordered only by customer_id
- Use ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY updated_at DESC, ingestion_id DESC) and keep row 1
- Use SELECT DISTINCT on every column
- Group by customer_id and take MAX(updated_at) with an arbitrary address
Comments — 0
Sign in to comment