oracle取最近一个非工作日下午六点
0
假如日期表里已经打好标记1为节假日,0是工作日,应为要算一些考核员工的周期,想刨除非工作时间,即节假日往前取最近一个工作日的下午6点。oracle循环不太熟还请大家帮忙指点。
示例数据:
select '2017-01-01' as day_date ,0 as is_holiday from dual
union all
select '2017-01-02' as day_date ,0 as is_holiday from dual
union all
select '2017-01-03' as day_date ,0 as is_holiday from dual
union all
select '2017-01-04' as day_date ,1 as is_holiday from dual
union all
select '2017-01-05' as day_date ,1 as is_holiday from dual
示例数据:
select '2017-01-01' as day_date ,0 as is_holiday from dual
union all
select '2017-01-02' as day_date ,0 as is_holiday from dual
union all
select '2017-01-03' as day_date ,0 as is_holiday from dual
union all
select '2017-01-04' as day_date ,1 as is_holiday from dual
union all
select '2017-01-05' as day_date ,1 as is_holiday from dual
没有找到相关结果
重要提示:提问者不能发表回复,可以通过评论与回答者沟通,沟通后可以通过编辑功能完善问题描述,以便后续其他人能够更容易理解问题.
2 个回复
seng - 从事BI、大数据、数据分析工作 2017-01-06 回答
赞同来自: 菲克
select t1.day_desc, max(t2.day_desc)
from table t1 left join table t2 on(t1.day_desc >= t2.day_desc and t2.is_holiday ='0')
group by t1.day_desc
order by t1.day_desc
老头子 - 专注是唯一的捷径 2017-01-06 回答
赞同来自: 菲克
比如1月8日是周日,最近一个工作日是要取1月9还是1月6?