Oracle case when 的使用,用数据库自身的时间计算,也比较方便。
判断有效期截止时间是否过期的几种状态
case
when t.expire_date is null then 0
when t.expire_date - sysdate >= 90 then 1
when t.expire_date - sysdate >= 30 and 90 > t.expire_date - sysdate then 2
when t.expire_date - sysdate >= 0 and 30 > t.expire_date - sysdate then 3
else 4
end state,