20_city.sql 707 B

12345678910111213141516171819202122232425262728
  1. --20、PUE超标率
  2. ---地市
  3. select
  4. '202206' as MONTH_ID,
  5. '地市' as ZB_TYPE,
  6. '河北' as PROV_NAME,
  7. dg.city_code*100 as CITY_ID,
  8. a.city_name as CITY_NAME,
  9. null as GRID_ID,
  10. null as GRID_NAME,
  11. '20' as ZB_CODE,
  12. 'PUE超标率' as ZB_NAME,
  13. '是' as IS_RATIO,
  14. pue_total as QZ_FZ,
  15. pue_over as QZ_FM,
  16. pue_over_rate as BY_QZ
  17. from
  18. (select
  19. case when city_name='雄安新区' then '雄安' else city_name end,
  20. count(*) as pue_total,
  21. sum(case when pue>1.5 then 1 else 0 end) as pue_over,
  22. sum(case when pue>1.5 then 1 else 0 end)/count(*)::numeric as pue_over_rate
  23. from sqmdb_cost.pue_top
  24. group by city_name) a
  25. join
  26. (select distinct city_code,city_sname from sqmdb_cost.dict_grid) dg
  27. on a.city_name=dg.city_sname
  28. order by dg.city_code