計算兩個日期之間的工作天數

返回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;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章