Hi
I have this SQL in ORACLE
This returns 4 rows, what I want is to calculate the how many pct the discount is.
Some thing like this
But I can't get it to work.
Hope someone can help
/LHG
I have this SQL in ORACLE
Code:
SELECT
SUM(num_of_calls) AS SMS_CALLS,
SUM(NVL(actv_amt,0))+SUM(NVL(-discount_amt,0)) AS total_charge,
SUM(NVL(discount_amt,0)) AS DISCOUNT,
SUM(NVL(actv_amt,0)) AS BILLED,
FROM charge c1
WHERE actv_bill_seq_no = (SELECT ba.bl_last_rg_bl_seq_no FROM billing_account ba WHERE c1.ban = ba.ban)
AND feature_category IN ('GGSM', 'NBR1', 'NBR3', 'NBR4', 'NBR5', 'NBR6', 'NBZO',
'NDAT', 'NEUR', 'NF2M','NFAX','NFLG','NFP0','NFSM','NGP1','NHSD','NHZO','NIAC','NMDA','NMPG','NOZO','NSG0','NSO6','NST1','NSTA','NUDP')
AND ROOT_BAN=99999999;
This returns 4 rows, what I want is to calculate the how many pct the discount is.
Some thing like this
Code:
SELECT
SUM(num_of_calls) AS SMS_CALLS,
SUM(NVL(actv_amt,0))+SUM(NVL(-discount_amt,0)) AS total_charge,
SUM(NVL(discount_amt,0)) AS DISCOUNT,
SUM(NVL(actv_amt,0)) AS BILLED,
[b](DISCOUNT*-1)/total_charge AS DISC_PCT[/b]
FROM charge c1
WHERE actv_bill_seq_no = (SELECT ba.bl_last_rg_bl_seq_no FROM billing_account ba WHERE c1.ban = ba.ban)
AND feature_category IN ('GGSM', 'NBR1', 'NBR3', 'NBR4', 'NBR5', 'NBR6', 'NBZO',
'NDAT', 'NEUR', 'NF2M','NFAX','NFLG','NFP0','NFSM','NGP1','NHSD','NHZO','NIAC','NMDA','NMPG','NOZO','NSG0','NSO6','NST1','NSTA','NUDP')
AND ROOT_BAN=326626300;
But I can't get it to work.
Hope someone can help
/LHG