medium10 pts · first answer countssqlmergeupsert
Table state after a MERGE
target has (id, v): (1, 10), (2, 20), (3, 30). staging has (2, 25), (4, 40), (5, 50). After this MERGE, how many rows does target have and what is SUM(v)?
MERGE INTO target t USING staging s ON t.id = s.id WHEN MATCHED THEN UPDATE SET v = s.v WHEN NOT MATCHED THEN INSERT (id, v) VALUES (s.id, s.v);
Discussion 0
Join free to post in the discussion.
Related questions
- Purpose of a primary keyData Engineer
- Row count of a LEFT JOINData Engineer
- Filtering with = NULLData Engineer
- COUNT(*) vs COUNT(column)Data Engineer
- Filtering groups with HAVINGData Engineer
- Adding a number to NULLData Engineer
- Orders pointing to missing customersData Engineer
- Upserting into a target tableData Engineer