Home » SQL & PL/SQL » SQL & PL/SQL » DECODE - need an alias NAME.
DECODE - need an alias NAME. [message #11004] |
Sun, 29 February 2004 20:07 |
resy
Messages: 86 Registered: December 2003
|
Member |
|
|
hi,
please find the following query
select SL_NO,
decode( STAT_PERFORMING,0, (decode( STAT_SUBSTD, 0 ,(decode( STAT_DOUBTFUL, 0 , (decode( STAT_LOST, 0 ,
(decode( STAT_GOVT_PERF, 0 , (decode( STAT_GOVT_NON_PERF, 0 , (decode( STAT_SPL_MENTION, 0 , 0, STAT_SPL_MENTION)),
STAT_GOVT_NON_PERF)), STAT_GOVT_PERF)), STAT_LOST)), STAT_DOUBTFUL)), STAT_SUBSTD)), STAT_PERFORMING)DATA
from tfe_cred_classification where ACCOUNT_NO = 'sb001'
Here for the output returned by DECODE function, i've given an alias DATA, is there any way to display the selected column name as alias??
I mean if the first DECODE is getting worked in false part i'vll be getting the datas on STAT_PERFORMING column. In that case i want STAT_PERFORMING as the alias name.
Any kind of suggetions are higly appreciated.
Thanx.
|
|
|
Re: DECODE - need an alias NAME. [message #11021 is a reply to message #11004] |
Mon, 01 March 2004 07:00 |
Satish Shrikhande
Messages: 167 Registered: October 2001
|
Senior Member |
|
|
This is just an example ...
SELECT RO_NUM,SUM(OPERATION_CODE),SUM(OPERATION_CODE1)
FROM (select ro_num,
decode(substr(operation_code,1,1),'O',nvl(sum(operation_amt),0),0) operation_code,
decode(substr(operation_code,1,1),'O',0,nvl(sum(operation_amt),0)) operation_code1
from table1 group by ro_num,operation_code,substr(operation_code,1,1))
group by RO_NUM
Check this questiona dn i hope you will get your answer .
http://www.orafaq.com/cgi-bin/msgboard/view-thr.cgi?board=newbies&message=12880
|
|
|
Goto Forum:
Current Time: Thu Mar 28 12:15:45 CDT 2024
|