开发者

How to use a calculated column in where condition?

How to use a calculated column in the where condition in Oracle 9i?

I want to use something like

select decode (:pValue,1,
               select sysdate from dual,
               select activation_date from account where AcNo = 1234) as calDate
where caldate between 开发者_JAVA技巧startDate and endDate;


You can use an in-line view:

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;


You could select your date from dual and join the results:

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜