I am making a query where I classify a column by type and depending on this, place it if it is valid or not taken into account, this is the query I have:
select
nombre as nombre,
tipo_banco as tipo,
decode(tipo_banco,'PRIVADO',1,0) as valido,
case when valido = 1 then 'Válido' else 'No tomar en cuenta' end as valido2
from banco2
What I wanted to do was take that "valid" alias to know which ones have 1 but it doesn't work as I wanted and it throws me the following error:
ORA-00904: "VALIDO": invalid identifier 00904. 00000 - "%s: invalid identifier" *Cause:
*Action: Error at line: 236, column: 14
Line 236 is where the case when valido=1
...
Is there any way of doing this? I don't know if I explained well what I need to do, Thanks in advance
Yes. Most databases do not accept that you put the name of a field that you just generated in the same query...
What you have to do is repeat the function every time you need it.
The del syntax
CASE
in Oracle is somewhat different, subtle, but other than what you have, it should be