SQL Language (MOSC)

MOSC Banner

using alias in select statement

edited Oct 16, 2012 3:23AM in SQL Language (MOSC) 3 commentsAnswered ✓
 Hi,
I have this query:
select systemtype, SUM(CASE WHEN isflash(narserno)=1 THEN 1 ELSE 0 END)*100/COUNT(*) flash,
100-SUM(CASE WHEN isflash(narserno)=1 THEN 1 ELSE 0 END)*100/COUNT(*)
from systemconfig GROUP BY SYSTEMTYPE;

however, i want to replace it with:
select systemtype, SUM(CASE WHEN isflash(narserno)=1 THEN 1 ELSE 0 END)*100/COUNT(*) flash,
100-flash
from systemconfig GROUP BY SYSTEMTYPE;

it does not work and gives me this error:
ORA-00904: "FLASH": invalid identifier
00904. 00000 -  "%s: invalid identifier"
*Cause:    
*Action:
Error at Line: 27 Column: 4

my question is: why does it fail and how to make it work with out running that whole complex sum statement again.

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center