Sql 语句小问题
SELECT t1.reconcileno,t1.dealret,
t1.dealamout,
t2.amount,
(case
when t1.dealret = t2.amount then
'01'
else
'02'
end) as 处理结果
from t_reconcil_detail t1
join t_reconcil t2
on t1.reconcileno = t2.reconcileno
where t1.handleflag='1' and t2.reconcileret = '1'
请问查询后如何将处理结果插入到dealamout中?
------解决方案--------------------UPDATE T_RECONCIL_DETAIL T1
SET T1.DEALAMOUT =
(SELECT CASE
WHEN T1.DEALRET = T2.AMOUNT THEN
'01'
ELSE
'02'
END
FROM T_RECONCIL T2
WHERE T1.RECONCILENO = T2.RECONCILENO
AND T1.HANDLEFLAG = '1'
AND T2.RECONCILERET = '1')