select nvl2(delayday,plan_date - sysdate,plan_date - execute_date) from guigance最好能使日期格式一致.
改一下,将NVL2(DELAYDAY,....)改为NVL2(EXECUTE_DATE,...)
select delayday from guigance where (execute_date is null and delayday=plan-sysdate) or (execute_date is not null and delayday=plan-execute_date) 要求: oracle 9i的环境,并且dalayday、execute_date、plan_date都必须是date型 经过测试可以用的,一定要给分哦!o(∩_∩)o...
where (execute_date is null and delayday=plan-sysdate)
or (execute_date is not null and delayday=plan-execute_date)
要求:
oracle 9i的环境,并且dalayday、execute_date、plan_date都必须是date型
经过测试可以用的,一定要给分哦!o(∩_∩)o...
而1楼给出的计算结果,所以3楼的回答正确。
鉴定完毕!
日期型转为数字型就可以了!
select decode(delayday,
null,plan_date-to_number(to_char(sysdate,'yyyymmdd')),
plan_date-execute_date) as delayday
from guigance 与8楼的类似^_^