This website uses cookies to ensure you get the best experience.
Learn more.
A batch contains multiple updates per order. Which SQL pattern selects the latest timestamp per order before an upsert?
Published
- SELECT DISTINCT order_id, amount, updated_at only
- ORDER BY updated_at without per-key reduction
- ROW_NUMBER partitioned by order_id, ordered by updated_at descending, then keep row 1
- GROUP BY order_id and choose any amount without ordering
Comments — 0
Sign in to comment