20_grid.sql 798 B

1234567891011121314151617181920212223242526
  1. --20、PUE超标率
  2. ---网格
  3. select
  4. '202206' as MONTH_ID,
  5. '网格' as ZB_TYPE,
  6. '河北' as PROV_NAME,
  7. dcg.city_code*100 as CITY_ID,
  8. a.city_name as CITY_NAME,
  9. dcg.grid_code as GRID_ID,
  10. a.area_name as GRID_NAME,
  11. '20' as ZB_CODE,
  12. 'PUE超标率' as ZB_NAME,
  13. '是' as IS_RATIO,
  14. a.pue_over as QZ_FZ,
  15. a.pue_total as QZ_FM,
  16. a.pue_over_rate as BY_QZ
  17. from
  18. (select city_name_short(city_name) as city_name,area_name,
  19. count(*) as pue_total,
  20. sum(case when pue>1.5 then 1 else 0 end) as pue_over,
  21. sum(case when pue>1.5 then 1 else 0 end)/count(*)::numeric as pue_over_rate
  22. from sqmdb_cost.pue_top
  23. group by city_name,area_name) a
  24. join sqmdb_cost.dict_grid_code dgc on a.city_name=dgc.city_name and trim(a.area_name)=trim(dgc.grid_name)
  25. join sqmdb_cost.dict_code_grid dcg on dgc.grid_code=dcg.grid_code
  26. order by dcg.city_code