oracle语句怎么查工作日,SQL查询工作日 - Oracle开发 - ITPUB论坛-中国专业的IT技术社区...

with t1 as (

/*连续的日期*/

SELECT to_date('2016-01-01', 'yyyy-mm-dd') + (level - 1) as normal_date

FROM dual CONNECT BY TRUNC(to_date('2016-01-01', 'yyyy-mm-dd')) + level - 1 <= TRUNC(to_date('2016-02-29','yyyy-mm-dd'))

),

t2 as (

select '2016-01-01' as special_date,'N' as type,'法定节假日' as note from dual

union

select '2016-01-02' as special_date,'N' as type,'法定节假日' as note from dual

union

select '2016-01-03' as special_date,'N' as type,'法定节假日' as note from dual

union

select '2016-02-06' as special_date,'Y' as type,'补工作日' as note from dual

union

select '2016-02-07' as special_date,'N' as type,'法定节假日' as note from dual

union

select '2016-02-08' as special_date,'N' as type,'法定节假日' as note from dual

union

select '2016-02-09' as special_date,'N' as type,'法定节假日' as note from dual

union

select '2016-02-10' as special_date,'N' as type,'法定节假日' as note from dual

union

select '2016-02-11' as special_date,'N' as type,'法定节假日' as note from dual

union

select '2016-02-12' as special_date,'N' as type,'法定节假日' as note from dual

union

select '2016-02-13' as special_date,'N' as type,'法定节假日' as note from dual

union

select '2016-02-14' as special_date,'Y' as type,'补工作日' as note from dual

)

/*去除周末*/

select to_char(t1.normal_date,'yyyy-mm-dd') as normal_date from t1,t2 where TO_CHAR(t1.normal_date, 'd') NOT IN (1, 7) and t1.normal_date <> to_date(t2.special_date,'yyyy-mm-dd') and t2.type = 'N'

union

select t2.special_date as normal_date from t2 where t2.type = 'Y'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值