27,580
社区成员
发帖
与我相关
我的任务
分享
--好乱啊,是这个意思??
select sum(case when [year]=2008 then 1 else 0 end) as [2008人数统计],
sum(case when [year]=2009 then 1 else 0 end) as [2009人数统计],
count(distinct 员工id) as [Total人数统计]
from
(
select 员工id, 2008 as [year] from [2008员工信息]
union
select 员工id, 2009 as [year] from [2009员工信息]
) A
select 2008人数统计,2009人数统计,合计人数 from(
select count(distinct 员工id) 2008人数统计 from 2008员工信息
left join
select count(distinct 员工id) 2009人数统计 from 2009员工信息
left join
select count(distinct 员工id) 合计人数 from (
select distinct 员工id 2008人数统计 from 2008员工信息
union
select distinct 员工id 2009人数统计 from 2009员工信息))