I need to update 2 columns from a given query but the problem is that the query has more than 2 columns, so this is the correct syntax if I take off the additional columns :
UPDATE myTable TAO
SET (TAO.BASE_AMT,TAO.TAX_CD_VAT_PCT) = (
SELECT SUM(decode(TAX_CD_VAT_PCT
, 0
, 0
,d.monetary_amount))
, MAX (D.TAX_CD_VAT_PCT)
FROM ps_VCHR_LINE_WTHD w
, PS_DISTRIB_LINE d
WHERE 1=1
-- some conditions
GROUP BY d.business_unit, d.voucher_id
ORDER BY 1, 2)
The Original query is like that:
SELECT d.business_unit, d.voucher_id,SUM(decode(TAX_CD_VAT_PCT
, 0
, 0
,d.monetary_amount))
, MAX (D.TAX_CD_VAT_PCT)
FROM ps_VCHR_LINE_WTHD w
, PS_DISTRIB_LINE d
WHERE 1=1
-- some conditions
GROUP BY d.business_unit, d.voucher_id
ORDER BY 1, 2)
So if I remove d.business_unit, d.voucher_id
will I have the same result? because I tried this in SQL developer when I remove it I don't get the same top rows.
Can someone Help?
Thanks.