|
多测试,我自己都不能确定绝对正确
Sql = " select 日期,姓名,iif(在职状态='离职',1,0) as 在职状态 from [数据表$a1:f" & r & "] where 日期>=#" & [S1].Value & "# and 日期<=#" & [T1].Value & "#"
Sql = " select max(日期) as 日期,姓名 from (" & Sql & ") group by 姓名 having sum(在职状态)<1"
Sql = " select 姓名,职位,班组 from (select c.姓名,iif(isnull(c.职位),d.职位,c.职位) as 职位,iif(isnull(c.职位), " _
& " iif(isnull(c.班组),d.班组,c.班组),iif(isnull(c.班组),d.班组,c.班组)) as 班组 from (select a.姓名, " _
& " b.职位,b.班组 from (" & Sql & ") a left join [数据表$a1:f" & r & "] b on a.姓名 " _
& " = b.姓名 and a.日期=b.日期) c left join [数据表$a1:f" & r & "] d on c.姓名= d.姓名) where 职位<>''and 班组<>'' group by 姓名,职位,班组 " |
|