Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Can I use an alias name is a where clause
DA Morgan wrote:
> Lig wrote:
>
>> The following select statement yeilds an error message ORA-00904: >> "Total": invalid identifier. >> >> select t.a + t.b + t.c Total >> from some_table t >> where Total > 0 >> >> Why can't the alias Total be used in the Where clause? >> >> Is there any workaround other than doing something horrible like below >> >> select * >> from (select t.a + t.b + t.c Total >> from some_table t) >> where Total > 0 >> >> >> >> Cheers >> Lig
> Serge ... please get yourself a copy of Oracle. Your answer is incorrect > because you assume, incorrectly, the syntax is invalid. The SQL > statement works just fine and the OP's problem is not syntactic.
careful with the irony.
Please read the OPs post again. He knows that this second statement
works (he just doesn't like it).
Until I get Oracle cleared with legal, try his first statement (his REAL issue):
select t.a + t.b + t.c Total
from some_table t where Total > 0
Then, teacher, tell us whether it works, and if not why not. If you still are convinced that my answer is incorrect, please educate me on why.
Tom Kyte shall be our judge whether the you, the Oracle expert, is correct or I, the SQL theorist ;-)
Cheers
Serge
-- Serge Rielau DB2 SQL Compiler Development IBM Toronto LabReceived on Wed Mar 09 2005 - 17:49:13 CST
![]() |
![]() |