17,086
社区成员
发帖
与我相关
我的任务
分享
select
(case
when length(sysdate)=10 and substr(sysdate,0,1)!='2'
then to_date((to_char(sysdate,'yyyy')||'-'||substr(sysdate,0,2)||'-'||substr(sysdate,3,2)),'yyyy-MM-dd')
else sysdate
end)
from dual d
应该这样才行,then和else的结果类型应该要一致。不能一个是date,一个是字符。
select
(case
when substr(time2,0,1)!='2'
then to_date((to_char(sysdate,'yyyy')||'-'||substr(time2,0,2)||'-'||substr(time2,3,2)),'yyyy-MM-dd')
else to_date(time2,'yyyy-mm-dd')
end)
from table2 d