I have the below query
SELECT decode(detl_cd,'AAA',trunc(amt * to_number(pct) / 100,2),
'BBB',trunc(amt * to_number(pct) / 100,2),
'CCC',(amt-trunc(amt * to_number(pct) / 100,2))
INTO trans_amount
FROM dual;
I get the value detl_cd from a cursor and amt from an input file.
Select tb1.id, tb2.detl_cd,tb2.pct
from tb1
join tb2 on tb1.agent_code=tb2.agent_code
where tb1.id='1';
Each id has 3 detl cd's and each detl code has different calculation. How to avoid hardcode in decode. Creating a table is not an option.
Input file
ID Amount
1 1000
2 2500
3 350
Id 1 & 2 belong to a group that is assigned 3 different detl cd's and different precentage(pct).
output file
ID Detl_cd Amount
1 AAA1 250
1 BBB1 250
1 CCC1 750
2 AAA3 625
2 BBB3 625
2 CCC3 1875
3 350
Each ID has 3 different detl_cd's but the calculation for AAA1 and AAA2 are the same so is BBB & CCC.
I guess you may want