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