oracle中计算某月的天数

oracle中计算某月的天数:

程序中在to_date(参数,'mm')输入参数就可以了

select to_date('03','mm') from dual
--输出
--2021/3/1

select add_months(to_date('202102', 'YYYYMM'),1)-to_date('202102', 'YYYYMM') 
from dual --输出 --28 --例:查询机器人月平均每日报警次数,当月平均计算到当天 select idrobot,mon,errortype,count(*)sum_error, case when trunc(sysdate,'mm')=to_date(mon,'mm')
then round(count(*)/(trunc(sysdate)-trunc(sysdate,'mm')),2) else round(count(*)/(to_date(mon+1,'mm')-to_date(mon,'mm')),2) end as error_day from 表a group by idrobot,mon,errortype order by substr(idrobot,5,6),mon,errortype
原文地址:https://www.cnblogs.com/bellin124/p/14610217.html