MERGE INTO dms_wl_info a ----> 目标表
USING ( SELECT c.position, SUM (c.store_qt) COUNT
FROM dms_goods_stock c
LEFT JOIN sys_office d ON d.id = C.BELONG_DEPARTMENT --> 辅助表(包含目标表需要的数据)
WHERE c.position IS NOT NULL
<if test="warehouse != null and warehouse != ''">
AND D.PARENT_IDS LIKE '%'||#{warehouse}||'%' --> 动态修改
</if>
GROUP BY c.position) b
ON (a.wl_id = b.position) --> 条件
WHEN MATCHED
THEN
UPDATE SET a.can_save_qt = A.MAX_QT - b.COUNT --> 修改语句,可以插入insert ,输出结果 output等
还有一种批量修改 update_select 语句 参看
https://www.cnblogs.com/yelanggu/p/6489515.html