xxxxxxxxxx
merge into target using (select k, max(v) as v from src group by k) as b on target.k = b.k
when matched then update set target.v = b.v
when not matched then insert (k, v) values (b.k, b.v);
xxxxxxxxxx
MERGE INTO target USING (select k, max(v) as v from src group by k) AS b ON target.k = b.k
WHEN MATCHED THEN UPDATE SET target.v = b.v
WHEN NOT MATCHED THEN INSERT (k, v) VALUES (b.k, b.v);