With test_from AS (
SELECT 5 as id
)
MERGE A USING test_from
ON ( A.id = test_from.id ) -- 条件是 id 相同
WHEN MATCHED THEN UPDATE SET A.zongliang = A.zongliang + 1 -- 匹配的时候,更新
WHEN NOT MATCHED THEN INSERT VALUES(test_from.id, 1) -- 源表有,目标表没有,插入
没测试过, 你先跑一下看看?