赞
踩
1、从业务编号中拆分出日期:RC_20201221_102
2、获取系统日期
3、直接可以做减法,把结果分成四列显示
4、最后外部套一个查询,用count()计数
select count(类别) as 当天病害,count(类别2) as 非24小时病害,count(类别3) as 前一天病害,count(SPORADIC_CODE) as 病害总量 from(
select SPORADIC_CODE, case
when (select to_char(sysdate, 'yyyyMMdd' ) from dual) - substr(SPORADIC_CODE , 4,8) = 0 then '24小时病害'
end as 类别,case
when (select to_char(sysdate, 'yyyyMMdd' ) from dual) - substr(SPORADIC_CODE , 4,8) != 0 then '非24小时病害'
end as 类别2,case
when (select to_char(sysdate, 'yyyyMMdd' ) from dual) - substr(SPORADIC_CODE , 4,8) = 1 then '前一天病害'
end as 类别3
from R_SPORADIC
)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。