123456789101112131415161718192021222324252627282930 |
- --22、超高电价占比
- ---网格
- 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,
- '22' as ZB_CODE,
- '超高电价占比' as ZB_NAME,
- '是' as IS_RATIO,
- a.high_price_num as QZ_FZ,
- a.total_num as QZ_FM,
- a.high_price_rate as BY_QZ
- from
- (select smonth,grid_code,
- count(*) as total_num,
- sum(case when y.eprice>0.8 then 1 else 0 end) as high_price_num,
- sum(case when y.eprice>0.8 then 1 else 0 end)/count(*)::numeric as high_price_rate
- from
- (select yn.smonth,dgc.grid_code,(case when accrued_power=0 then 0 else accrued_cost/accrued_power end) as eprice
- 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='202207') y
- group by smonth,grid_code) a
- join sqmdb_cost.dict_code_grid dcg on a.grid_code=dcg.grid_code
- order by dcg.city_code
|