I have got a query like
select distinct i.charge_type, cp.name, sum(i.amount)
from charge.gp_schedule gp, charge.gsm_charge_plan i, charge cp
where i.code = gp.sales_audit_code
and cp.code = gp.code
group by i.charge_type ,cp.name
which outputs for example the following
GSMFixedCharge FCFBBR15 15
**GSMUsageCharge** Call Charges 2.16
**GSMUsageCharge** Service Charges 2
GSMFixedCharge Line Rental 23.98
GSMFixedCharge FCFAFPBL 1
How can I further sum the values only based on 'GSMUsageCharge' in the same query so the desired output would be
GSMFixedCharge FCFBBR15 15
GSMUsageCharge Call Charges 4.16
GSMFixedCharge Line Rental 23.98
GSMFixedCharge FCFAFPBL 1
I have tried something like
select distinct i.charge_type, cp.name, DECODE(i.charge_type, 'GSMUsageCharge', sum (i.amount)
group by i.charge_type) result
but it does not work...
cp.namebecause with it you can't group therefore you can't sum. is it really needed?