08_city.sql 1.1 KB

12345678910111213141516171819202122232425262728
  1. --08、网络能耗占收比
  2. ---地市
  3. select
  4. a.smonth as MONTH_ID,
  5. '地市' as ZB_TYPE,
  6. '河北' as PROV_NAME,
  7. dg.city_code*100 as CITY_ID,
  8. a.sname as CITY_NAME,
  9. null as GRID_ID,
  10. null as GRID_NAME,
  11. '8' as ZB_CODE,
  12. '网络能耗占收比' as ZB_NAME,
  13. '是' as IS_RATIO,
  14. a.cost_nenghao as QZ_FZ,
  15. b.income_year as QZ_FM,
  16. case when b.income_year=0 then null else a.cost_nenghao/b.income_year end as BY_QZ
  17. from
  18. (select '202206' as smonth,sname,stype,
  19. sum(column5+column19+column27+column41+column49+column57+column70+column78+column86+column94+column100+column108+column115)/10000 as cost_nenghao
  20. from sqmdb_cost.report50 where period_type='M' and stype ='北方省汇总展现' and smonth between '202201' and '202206' group by sname,stype) a
  21. left join
  22. (select report_id,smonth,sname,stype,column4 as income_year from sqmdb_cost.report80040) b
  23. on a.smonth=b.smonth and a.sname=b.sname
  24. join
  25. (select distinct city_code,city_pro from sqmdb_cost.dict_grid) dg
  26. on a.sname=dg.city_pro
  27. where a.sname in ('石家庄_河北','唐山_河北','秦皇岛_河北','邯郸_河北','邢台_河北','保定_河北','张家口_河北','承德_河北','廊坊_河北','沧州_河北','衡水_河北','雄安_河北')
  28. order by dg.city_code