Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> alias name in a group by does not work

alias name in a group by does not work

From: Christian Förster <christian.nospam_at_foersterle.de>
Date: 15 May 2003 04:27:02 -0700
Message-ID: <c74b41b1.0305150327.26e0c76a@posting.google.com>


Like the topic said:

select
 col1,
 case when col1 > col3 then 'YES' else 'NO' end as STATUS,  col2
from testtable
group by col1, STATUS;

does not work!?
It results in: ORA-00904 unknown column

The only way to do it:

select
 col1,
 case when col1 > col3 then 'YES' else 'NO' end as STATUS,  col2
from testtable
group by col1, case when col1 > col3 then 'YES' else 'NO' end;

Is there a way to use the alias name in the group by part anyway? (In other db, i.e. sybase this is no problem ;-) )

Cheers
Christian Received on Thu May 15 2003 - 06:27:02 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US