12345678910111213141516171819202122232425262728 |
- --21、转供电占比
- ---地市(可由网格数据汇聚)
- select
- a.smonth as MONTH_ID,
- '地市' as ZB_TYPE,
- '河北' as PROV_NAME,
- dg.city_code*100 as CITY_ID,
- a.city_name as CITY_NAME,
- null as GRID_ID,
- null as GRID_NAME,
- '21' as ZB_CODE,
- '转供电占比' as ZB_NAME,
- '是' as IS_RATIO,
- zgd_num as QZ_FZ,
- total_num as QZ_FM,
- zgd_rate as BY_QZ
- from
- (select smonth,city_name,
- count(*) as total_num,
- sum(case when y.meter_type_name='12-01 | 转供手抄表' then 1 else 0 end) as zgd_num,
- sum(case when y.meter_type_name='12-01 | 转供手抄表' then 1 else 0 end)/count(*)::numeric as zgd_rate
- from sqmdb_cost.ytmx_new y
- where build_type_name not in ('办公楼','办公用房','营业用房') and smonth='202206'
- group by smonth,city_name) a
- join
- (select distinct city_code,city_name from sqmdb_cost.dict_grid) dg
- on a.city_name=dg.city_name
- order by dg.city_code
|