我希望通过select statemenet设置值来更新记录。
查询看起来应该是这样的;
UPDATE FCR.HEADER
SET (Value1,Value2,Value3)
(SELECT sum(AMOUNT_FC),sum(AMOUNT_DC ), value1
FROM tableA
WHERE DATE = to_date('02/05/2006', 'dd/mm/yyyy')
GROUP BY UNIT_ID, TRX_DATE)
WHERE TRX_DATE = to_date('02/05/2006', 'dd/mm/yyyy')
AND column14 = 'some value'
此查询的正常格式是什么?
答案 0 :(得分:0)
UPDATE FCR.HEADER
SET Value1 = (SELECT sum(AMOUNT_FC)
FROM tableA
WHERE DATE = to_date('02/05/2006', 'dd/mm/yyyy')
GROUP BY UNIT_ID, TRX_DATE),
Value2 = (SELECT sum(AMOUNT_DC)
FROM tableA
WHERE DATE = to_date('02/05/2006', 'dd/mm/yyyy')
GROUP BY UNIT_ID, TRX_DATE),
Value3 = (SELECT sum(AMOUNT_DC)
FROM tableA
WHERE DATE = to_date('02/05/2006', 'dd/mm/yyyy')
GROUP BY UNIT_ID, TRX_DATE)
WHERE TRX_DATE = to_date('02/05/2006', 'dd/mm/yyyy')
AND column14 = 'some value'
最好使用Date类型的变量来保存to_date(...)。
希望这有帮助。