select a.单位,a.本科,b.硕士,c.博士, d.总个数
from
(select 单位,count(*) as 本科 from table where 学历 = '本科' group by 单位 ) as a,
(select 单位,count(*) as 硕士 from table where 学历 = '硕士' group by 单位 ) as b,
(select 单位,count(*) as 博士 from table where 学历 = '博士' group by 单位 ) as c,
(select 单位,count(*) as 总人数 from table group by 单位 ) as d
where
a.单位 = b.单位 and a.单位 = c.单位 and a.单位 = d.单位
select a.单位,本科,硕士,博士, 总个数
from
(select 单位,count(*) as 本科 from table where 学历 = '本科' group by 单位 ) as a,
(select 单位,count(*) as 硕士 from table where 学历 = '硕士' group by 单位 ) as b,
(select 单位,count(*) as 博士 from table where 学历 = '博士' group by 单位 ) as c,
(select 单位,count(*) as 总个数 from table group by 单位 ) as d
where
a.单位 = b.单位 and a.单位 = c.单位 and a.单位 = d.单位
select a.单位,本科,硕士,博士, 总个数
from
(select 单位,count(*) as 本科 from table where 学历 = '本科' group by 单位 ) as a,
(select 单位,count(*) as 硕士 from table where 学历 = '硕士' group by 单位 ) as b,
(select 单位,count(*) as 博士 from table where 学历 = '博士' group by 单位 ) as c,
(select 单位,count(*) as 总人数 from table group by 单位 ) as d
where
a.单位 = b.单位 and a.单位 = c.单位 and a.单位 = d.单位