您的位置:首页 > 数据库 > Oracle

计算两个日期之间的工作天数

2015-09-11 13:47 585 查看
返回A,B两个员工聘用日期之间的工作天数

create table test as

select level as id

from dual

connect by level<500;

select sum(case

                   when to_char(min_hd+test.id-1,'DY','NLS_DATE_LANGUAGE=American') in(‘SAT’,'SUN')

                   then 0

                   else 1

                   end) as 工作天数

from (select min(hiredate) as min_hd,max(hiredate) as max_hd

          from tab

          where name in('A','B')) x,test

where test.id<=max_hd-min_hd+1;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  oracle