开发者

SQL Query Update with Select

I wish to update a record by setting the values through an select statemenet..

The query should look something like this;

UPDATE FCR.HEADER
SET (Value1,Value2,Value3)

(SELECT sum(AMOUNT_FC),sum(AMOUNT_DC ), value1 
FROM tableA
WHERE DATE = to_date('02/0开发者_开发知识库5/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' 

What is the proper format in order for this query to work ?


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' 

it would be better to have a Variable of type Date to hold to_date(...).

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜