SELECT TOP 1048575 "dbo"."employee_all"."rno" AS "rno", "dbo"."employee_all"."rname" AS "rname",
"dbo"."employee_all"."sex" AS "sex", "dbo"."employee_all"."checkdate" AS "checkdate",
"dbo"."employee_all"."outdate" AS "outdate", "dbo"."employee_all"."staus" AS "staus",
"Hrt Department"."remark" AS "Hrt Department__remark"
FROM "dbo"."employee_all"
LEFT JOIN "dbo"."HRT_DEPARTMENT" "Hrt Department" ON "dbo"."employee_all"."depno" = "Hrt Department"."depno"
where (select distinct top 100 percent CONVERT (varchar(7),checkdate,120)'日期',sum(case when CONVERT (varchar(7),checkdate,120) >='2021-01' then 1 end )'入职',b.lz '离职' from employee_all a
left join
(select distinct convert (varchar(7),outdate,120) rq ,sum(case when outdate >0 then 1 else 0 end) lz from employee_all
where CONVERT (varchar(7),outdate,120) >='2021-01' group by convert (varchar(7),outdate,120)) b on b.rq=CONVERT (varchar(7),a.checkdate,120)
where CONVERT (varchar(7),checkdate,120) >='2021-01'
group by CONVERT (varchar(7),checkdate,120) ,b.lz order by CONVERT (varchar(7),checkdate,120))
SQL新手,求教