Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Hi, you need to put all of the keys in the ON part of the clause rather then in the where condition. This code works:
MERGE INTO target_table AS target
USING source_table AS source
ON target.key1 = source.key1
AND target.key2 = source.key2
AND target.key3 = source.key3
WHEN MATCHED AND source.rn1 = 1 THEN
UPDATE SET val = source.val
WHEN MATCHED AND source.rn2 = 1 THEN
UPDATE SET val = source.val
WHEN MATCHED AND source.rn3 = 1 THEN
UPDATE SET val = source.val