日期:2014-05-17 浏览次数:20974 次
select MC,ZJBH,XZQ,SLRQ,SFHMD,DQSJ, case when DQSJ is null or DQSJ-sysdate>45 then '正常' when DQSJ-sysdate>0 and DQSJ-sysdate<=45 then '快到期' when DQSJ-sysdate<=0 then '到期' end DQZT from USER_ZGINFO
------解决方案--------------------
create table t1(d_date date);
insert into t1 values (to_date('2012-06-01 12:00:00','yyyy-mm-dd hh24:mi:ss'));
insert into t1 values (to_date('2012-03-01 12:00:00','yyyy-mm-dd hh24:mi:ss'));
insert into t1 values (to_date('2012-04-01 12:00:00','yyyy-mm-dd hh24:mi:ss'));
insert into t1 values (to_date('2012-05-01 12:00:00','yyyy-mm-dd hh24:mi:ss'));
select d_date,
case when d_date-sysdate>45 then '正常'
when d_date-sysdate<=45 and d_date-sysdate>0 then '快到期'
when d_date-sysdate<=0 then '到期' end d_state
from t1
d_date d_state
---------------------------------------------
1 2012/6/1 12:00:00 正常
2 2012/3/1 12:00:00 到期
3 2012/4/1 12:00:00 快到期
4 2012/5/1 12:00:00 快到期