一则数据统计的SQL语句

select t.unitid,t.unitname,j1,j2,j3,j4,j5,j6,j7,j8,j9,j10,j11,j12,j13 from

(select unitid,count(*) as j1 from
(select rpad(userid,6,'0')||'000000' as unitid  ,spec from tbltechman)
where spec='01' group by unitid) a,
(select unitid,count(*) as j2 from
(select rpad(userid,6,'0')||'000000' as unitid  ,spec from tbltechman)
where spec='02' group by unitid) b,
(select unitid,count(*) as j3 from
(select rpad(userid,6,'0')||'000000' as unitid  ,spec from tbltechman)
where spec='03' group by unitid) c,
(select unitid,count(*) as j4 from
(select rpad(userid,6,'0')||'000000' as unitid  ,spec from tbltechman)
where spec='04' group by unitid) d,
(select unitid,count(*) as j5 from
(select rpad(userid,6,'0')||'000000' as unitid  ,spec from tbltechman)
where spec='05' group by unitid) e,
(select unitid,count(*) as j6 from
(select rpad(userid,6,'0')||'000000' as unitid  ,spec from tbltechman)
where spec='06' group by unitid) f,
(select unitid,count(*) as j7 from
(select rpad(userid,6,'0')||'000000' as unitid  ,spec from tbltechman)
where spec='07' group by unitid) g,
(select unitid,count(*) as j8 from
(select rpad(userid,6,'0')||'000000' as unitid  ,spec from tbltechman)
where spec='08' group by unitid) h,
(select unitid,count(*) as j9 from
(select rpad(userid,6,'0')||'000000' as unitid  ,spec from tbltechman)
where spec='09' group by unitid) i,
(select unitid,count(*) as j10 from
(select rpad(userid,6,'0')||'000000' as unitid  ,spec from tbltechman)
where spec='10' group by unitid) j,
(select unitid,count(*) as j11 from
(select rpad(userid,6,'0')||'000000' as unitid  ,spec from tbltechman)
where spec='11' group by unitid) k,
(select unitid,count(*) as j12 from
(select rpad(userid,6,'0')||'000000' as unitid  ,spec from tbltechman)
where spec='12' group by unitid) l,
(select unitid,count(*) as j13 from
(select rpad(userid,6,'0')||'000000' as unitid  ,spec from tbltechman)
where spec='13' group by unitid) m,

(select unitid,unitname from tblunit where unitid like '5227%000000' order by unitid) t

where t.unitid=a.unitid(+) and t.unitid=b.unitid(+) and t.unitid=c.unitid(+) and t.unitid=d.unitid(+)
and t.unitid=e.unitid(+) and t.unitid=f.unitid(+) and t.unitid=g.unitid(+) and t.unitid=h.unitid(+)
and t.unitid=i.unitid(+) and t.unitid=j.unitid(+) and t.unitid=k.unitid(+) and t.unitid=l.unitid(+)
and t.unitid=m.unitid(+)

order by unitid
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值