Hi All,
There are two rows in the table, one is the discount record, one is the normal amount. Data as below:
txn_id txn_typedocket_voucher_numberamt ...
121113226 5 002712 86.88
121116789 2 002712-3.41
I want to use subquery the table by taking the two amts (both '86.88' and '-3.41')
expected return result should be:
txn_id txn_typedocket_voucher_numberamt discount_amt
121113226 5 002712 86.88 -3.41
I had the following query which is not working at the moment:
select txn_id,
txn_type,
docket_voucher_number,
amt,
(select tn.amt
from txn tn
where tn.docket_voucher_number = t.docket_voucher_number) discount_amt
from txn t
INNER JOINcons_chain_tab cct
ONt.cust_id= cct.cust_id
INNER JOIN cust_fin cf
ONcct.account_cust_id = cf.cust_id
ANDt.txn_type=5
ANDt.system_date_loaded >= '20100517'
AND t.system_date_loaded < '20100617'
WHEREcf.plan_id='CX'
Please help with this. It's quite urgent.
Cheers,
Chris
This person has no signature.