如何在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;

其他提示

您可以选择从双您的日期和加入的结果:

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
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top