问题:给定两个日期,求它们之间(包括这两个日期本身)有多少个”工作“日。
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 ;

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
  • 2022-12-23
  • 2021-05-20
  • 2022-12-23
  • 2021-07-08
  • 2022-12-23
猜你喜欢
  • 2022-03-09
  • 2021-12-26
  • 2021-12-15
  • 2022-12-23
  • 2022-12-23
  • 2021-09-28
相关资源
相似解决方案