Demo entry 6336046

sql

   

Submitted by kisn on Dec 07, 2016 at 03:29
Language: SQL. Code size: 1.2 kB.

--全国省市县的人员平均人数sql
select count(*) as 人员总数,
       count(distinct p.orgcode) as 机构总数,
       round(count(*) / count(distinct p.orgcode), 0) as 平均人数
  from bs_person_baseinfo p
 where p.years = '2015'
   and p.status = '01'
   and p.orgcode in (select O.ORGCODE
                       from organise o
                      where o.SUB = '1' --省市县
                        and o.JIKONGZHONGXIN='1' 
                        and (o.IS_XN_CDC='0' or o.IS_XN_CDC is null) 
                        and o.ECOMTYPE = 'J100')
--分东中西,省市县的平均人数sql
select count(*) as 人员总数,
       count(distinct p.orgcode) as 机构总数,
       round(count(*) / count(distinct p.orgcode), 0) as 平均人数
  from bs_person_baseinfo p
 where p.years = '2015'
   and p.status = '01'
   and p.orgcode in
       (select O.ORGCODE
          from organise o
         where o.SUB = '3' --省市县(123)
           and o.ECOMTYPE = 'J100'
           and o.JIKONGZHONGXIN = '1'
           and (o.IS_XN_CDC = '0' or o.IS_XN_CDC is null)
           and substr(o.apanagecode, 0, 2) || '000000' in
               (select z.zonecode from zonecode z where z.LOCATIONTYPE = '3'))--东中西(123)

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).