Re: [SQL ] 请问如何计算重复日期区间的总实际天数

楼主: cutekid (可爱小孩子)   2014-09-19 09:33:26
假设 (id,StartDate,EndDate) 是“唯一”:
select id,sum(day) day
from (
select id,StartDate,EndDate,min(day) day
from (
select t2.id,t2.StartDate,t2.EndDate,
case
when t1.StartDate = t2.StartDate and t1.EndDate = t2.EndDate
then t2.day

Links booklink

Contact Us: admin [ a t ] ucptt.com