8.3 确定两个日期之间的工作日数目

问题:给定两个日期,求它们之间(包括这两个日期本身)有多少个”工作“日。
select sum(case
             when date_format(
             date_add(jones_hd,interval t500.id - 1, 'DY'),'%a')
             in ('SAT', 'SUN') 
             then 0 else 1
           end) as days
  from (select max(case
                     when ename = 'BLAKE' then
                      hiredate
                   end) as blake_hd,
               max(case
                     when ename = 'JONES' then
                      hiredate
                   end) as jones_hd
          from emp
         where ename in ('BLAKE', 'JONES')) x,
       t500
 where t500.id <= datediff(blake_hd, jones_hd) + 1 ;

原文地址:https://www.cnblogs.com/liang545621/p/7523298.html