1234567891011121314151617181920212223242526272829 |
- --21、转供电占比
- ---网格
- select
- a.smonth as MONTH_ID,
- '网格' as ZB_TYPE,
- '河北' as PROV_NAME,
- dcg.city_code*100 as CITY_ID,
- dcg.city_name as CITY_NAME,
- dcg.grid_code as GRID_ID,
- dcg.grid_name as GRID_NAME,
- '21' as ZB_CODE,
- '转供电占比' as ZB_NAME,
- '是' as IS_RATIO,
- a.zgd_num as QZ_FZ,
- a.total_num as QZ_FM,
- a.zgd_rate as BY_QZ
- from
- (select yn.smonth,dgc.grid_code,
- count(*) as total_num,
- sum(case when yn.meter_type_name='12-01 | 转供手抄表' then 1 else 0 end) as zgd_num,
- sum(case when yn.meter_type_name='12-01 | 转供手抄表' then 1 else 0 end)/count(*)::numeric as zgd_rate
- from sqmdb_cost.ytmx_new yn
- join sqmdb_cost.dict_grid_code dgc
- on city_name_short(yn.city_name)=dgc.city_name and trim(yn.area_name)=trim(dgc.grid_name)
- where yn.build_type_name not in ('办公楼','办公用房','营业用房') and yn.smonth='202206'
- group by yn.smonth,dgc.grid_code) a
- join sqmdb_cost.dict_code_grid dcg on a.grid_code=dcg.grid_code
- order by dcg.city_code
|