110,556
社区成员
发帖
与我相关
我的任务
分享
select 自动编号,姓名,身份类别,休假类别,休假时间 as 休假开始时间,休假时间2 as 休假结束时间,datediff(Day,休假时间, 休假时间2) + 1 as 合计天数,科室,(select sum(datediff(Day,休假时间, 休假时间2) + 1) from hsxjtj where 姓名 = t.姓名 and 休假时间2 <= t.休假时间2) from hsxjtj t group by 科室,姓名,身份类别,休假类别,休假时间,休假时间2,累计天数,自动编号
-- 以这个为准
select 自动编号,姓名,身份类别,休假类别,休假时间 as 休假开始时间,休假时间2 as 休假结束时间,datediff(Day,休假时间, 休假时间2) + 1 as 合计天数,科室,(select sum(datediff(Day,休假时间, 休假时间2) + 1) from hsxjtj where 姓名 = t.姓名 and 休假时间2 <= t.休假时间2) as 累计天数 from hsxjtj t group by 科室,姓名,身份类别,休假类别,休假时间,休假时间2,累计天数,自动编号