Home » SQL & PL/SQL » SQL & PL/SQL » Question on sum up of 2 columns that created by "decode" function
Question on sum up of 2 columns that created by "decode" function [message #197083] |
Mon, 09 October 2006 22:41 |
pcgame4u
Messages: 14 Registered: July 2006
|
Junior Member |
|
|
SELECT BILLED_EVENT_CODE,SERVICE_ID,
sum(decode(entitlement_flag,'A',1,0)) flag_A,
sum(decode(entitlement_flag,'P',1,0)) flag_P,
sum(decode(entitlement_flag,'C',1,0)) flag_C
FROM BUE.BUE_BILLED_IP_SDR_00008053
WHERE ENTITLEMENT_FLAG IN('A','P','C')
GROUP BY BILLED_EVENT_CODE,SERVICE_ID;
now i want to sum 2 columns, for examples <flag_A && flag_P>
then how can i do this in effective way?
thanks all brothers help.
|
|
|
Re: Question on sum up of 2 columns that created by "decode" function [message #197087 is a reply to message #197083] |
Mon, 09 October 2006 22:54 |
pcgame4u
Messages: 14 Registered: July 2006
|
Junior Member |
|
|
pcgame4u wrote on Mon, 09 October 2006 22:41 |
SELECT BILLED_EVENT_CODE,SERVICE_ID,
sum(decode(entitlement_flag,'A',1,0)) flag_A,
sum(decode(entitlement_flag,'P',1,0)) flag_P,
sum(decode(entitlement_flag,'C',1,0)) flag_C
FROM BUE.BUE_BILLED_IP_SDR_00008053
WHERE ENTITLEMENT_FLAG IN('A','P','C')
GROUP BY BILLED_EVENT_CODE,SERVICE_ID;
now i want to sum 2 columns, for examples <flag_A && flag_P>
then how can i do this in effective way?
thanks all brothers help.
|
i have try and here is my result.
SELECT BILLED_EVENT_CODE,SERVICE_ID,
sum(decode(entitlement_flag,'A',1,0)) +
sum(decode(entitlement_flag,'P',1,0)) flag_AP,
sum(decode(entitlement_flag,'C',1,0)) flag_C
FROM BUE.BUE_BILLED_IP_SDR_00008053
WHERE ENTITLEMENT_FLAG IN('A','P','C')
GROUP BY BILLED_EVENT_CODE,SERVICE_ID;
[Updated on: Mon, 09 October 2006 22:55] Report message to a moderator
|
|
|
Re: Question on sum up of 2 columns that created by "decode" function [message #197116 is a reply to message #197087] |
Tue, 10 October 2006 02:05 |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
Does what you've tried not work? Looks ok to me.
You could trySELECT BILLED_EVENT_CODE,SERVICE_ID,
sum(decode(entitlement_flag,'A',1,'P',1,0)) flag_AP,
sum(decode(entitlement_flag,'C',1,0)) flag_C
FROM BUE.BUE_BILLED_IP_SDR_00008053
WHERE ENTITLEMENT_FLAG IN('A','P','C')
GROUP BY BILLED_EVENT_CODE,SERVICE_ID;
|
|
|
Goto Forum:
Current Time: Thu Dec 12 08:02:15 CST 2024
|