Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

Reference Alias in case statment

Posted on 2007-11-27
Medium Priority
5,240 Views
Hi Experts,

I'm wondering if you can reference a  alias column (columns added together) within a case statement:

The aslias columns is S_NET_INCM.

Select  SCPL,    EIN,    SOI_MAJ_CD,   SOI_DIV_CD,
NVL(NET_INCM, 0) +   NVL(S_NET_INCM_OTHR_RNTL, 0) +  NVL(S_NET_LTCG_LSS, 0) +
NVL(S_NET_STCG_LSS, 0) AS "S_NET_INCM" ,
NVL(NET_OTHR_INCM, 0),
CASE
WHEN  "S_NET_INCM: < 0 THEN
0
ELSE
S_NET_INCM_POS
END "S_NET_INCM_POS"
FROM ENTITY_ADDITIONAL JOIN CONTROL C USING (SCPL, EDIT_1_2)

Thanks

0
Question by:lfolku
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 9

Accepted Solution

joebednarz earned 500 total points
ID: 20359159
Something to try:

``````SELECT SCPL, EIN, SOI_MAJ_CD, SOI_DIV_CD, NET_OTHR_INCM,
CASE
WHEN S_NET_INCM < 0 THEN 0
ELSE S_NET_INCM_POS
END S_NET_INCM_POS
FROM (SELECT SCPL, EIN, SOI_MAJ_CD, SOI_DIV_CD,
NVL (NET_INCM, 0)
+ NVL (S_NET_INCM_OTHR_RNTL, 0)
+ NVL (S_NET_LTCG_LSS, 0)
+ NVL (S_NET_STCG_LSS, 0) S_NET_INCM,
NVL (NET_OTHR_INCM, 0) NET_OTHR_INCM
JOIN
CONTROL C USING (SCPL, EDIT_1_2)
``````
0

LVL 48

Expert Comment

ID: 20359235
A possible workaround:

SELECT a.SCPL, a.EIN ....,
CASE
WHEN  "a.S_NET_INCM: < 0 THEN
0
ELSE
S_NET_INCM_POS
END "S_NET_INCM_POS"
FROM
(Select SCPL,    EIN,    SOI_MAJ_CD,   SOI_DIV_CD,
NVL(NET_INCM, 0) +   NVL(S_NET_INCM_OTHR_RNTL, 0) +  NVL(S_NET_LTCG_LSS, 0) +
NVL(S_NET_STCG_LSS, 0) AS "S_NET_INCM" ,
NVL(NET_OTHR_INCM, 0) AS "NET_OTHR_INCM",
FROM ENTITY_ADDITIONAL JOIN CONTROL C USING (SCPL, EDIT_1_2)) a
0

Author Closing Comment

ID: 31411214
It worked.....thanks!!!
0

Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
Suggested Courses
Course of the Month10 days, 21 hours left to enroll