Cómo utilizar una columna calculada en donde la condición?
-
19-09-2019 - |
Pregunta
Cómo utilizar una columna calculada en la condición where
en Oracle 9i?
quiero usar algo como
select decode (:pValue,1,
select sysdate from dual,
select activation_date from account where AcNo = 1234) as calDate
where caldate between startDate and endDate;
Solución
Puede utilizar una visión en línea:
select calcdate from
(
select startDate, endDate,
decode (:pValue,1,
select sysdate from dual,
select activation_date from account where AcNo = 1234) as calcdate
)
where calcdate between startDate and endDate;
Otros consejos
Se puede seleccionar la fecha de la doble y unirse a los resultados:
select *
from <<your table with startDate and endDate columns>> -- Since you ommited the main "from" clause from your statement
, (
select decode( :pValue
, 1, sysdate
, ( select activation_date from account where AcNo = 1234 )
) as calDate
from dual
) c
where c.calDate between startDate and endDate
... -- any other conditions you may need
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow