Как использовать вычисляемый столбец в условии where?
-
19-09-2019 - |
Вопрос
Как использовать вычисляемый столбец в where
условие в Oracle 9i?
Я хочу использовать что-то вроде
select decode (:pValue,1,
select sysdate from dual,
select activation_date from account where AcNo = 1234) as calDate
where caldate between startDate and endDate;
Решение
Вы можете использовать встроенное представление:
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;
Другие советы
Вы могли бы выбрать свою дату из списка dual и присоединиться к результатам:
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
Не связан с StackOverflow