|
Subject:
|
Decode function to display result in same row
|
|
Posted By:
|
yogeshyl
|
Post Date:
|
7/2/2008 12:40:35 AM
|
How a decode function / statement in SQL can be written to display the result of the parameters used in decode statement in same row.
Given the table as follows: ITED_TED_CODE ITED_NET_LC_AMT AED 0 BED 42063 EDU CESS 841 SHECESS 421 BED CT3 6825 EDU CESS CT3 137 SHECESS CT3 68
The decode statements are as follows. NVL(DECODE(ITED_TED_CODE,'AED',ITED_NET_LC_AMT),0) AED, NVL(DECODE(ITED_TED_CODE,'BED',ITED_NET_LC_AMT),0) BED, NVL(DECODE(ITED_TED_CODE,'EDU CESS',ITED_NET_LC_AMT),0)EDU, NVL(DECODE(ITED_TED_CODE,'SHECESS',ITED_NET_LC_AMT),0) SHE, NVL(DECODE(ITED_TED_CODE,'BED CT3',ITED_NET_LC_AMT),0) BEDCT3, NVL(DECODE(ITED_TED_CODE,'EDU CESS CT3',ITED_NET_LC_AMT),0) EDUCT3, NVL(DECODE(ITED_TED_CODE,'SHECESS CT3',ITED_NET_LC_AMT),0) SHE_CT3,
When executed for the above data gives the output as follows : AED BED EDU_CESS SHECESS BED_CT3 EDU_CESS_CT3 0 42063 841 421 1400 196
Whereas i want the output in first row in each column, as follows
AED BED EDU_CESS SHECESS BED_CT3 EDU_CESS_CT3 0 42063 841 421 1400 196
Yogesh
|
|