17,382
社区成员




select t.chr_cl1,count(t.chr_cl2) from
(select distinct chr_cl1,chr_cl2 from zd_report_temp
where program_name in('INVGSTOT')
) t
group by chr_cl1
order by chr_cl1
select t.chr_cl1,count(t.chr_cl2) from
(select distinct chr_cl1,chr_cl2) from zd_report_temp
where program_name in('INVGSTOT')
) t
group by chr_cl1
order by chr_cl1
--创建部门表
create table department
(
chr_cl1 varchar2(100),
chr_cl2 varchar2(100)
)
--添加测试数据
insert into department
select 'A1供应部','罗杰泷' from dual union all
select 'A1供应部','罗杰泷' from dual union all
select 'A1供应部','罗杰泷' from dual union all
select 'A1供应部','张国' from dual union all
select 'C1系统支持','谢燕山' from dual union all
select 'C1系统支持','谢燕山' from dual
commit;
--部门人数统计
select chr_cl1 as 部门,count(distinct chr_cl2) as 人数 from department group by chr_cl1
--查询结果
A1供应部 2
C1系统支持 1
select t.chr_cl1,count(distinct t.chr_cl2)
--重復帖?
select chr_cl1,count(distinct(chr_cl2)) 人数
from zd_report_temp
group by chr_cl1;