15_city.sql 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. --15、活动ONU单端口能耗(月)
  2. ---地市
  3. select
  4. t1.smonth as MONTH_ID,
  5. '地市' as ZB_TYPE,
  6. '河北' as PROV_NAME,
  7. t1.city_code*100 as CITY_ID,
  8. t1.city_name as CITY_NAME,
  9. null as GRID_ID,
  10. null as GRID_NAME,
  11. '15' as ZB_CODE,
  12. '活动ONU单端口能耗(月)' as ZB_NAME,
  13. '否' as IS_RATIO,
  14. t1.cost_nenghao/10000 as QZ_FZ,
  15. t2.active_onu_num/10000 as QZ_FM,
  16. t1.cost_nenghao/t2.active_onu_num/6 as BY_QZ
  17. from
  18. (select a.smonth,dg.city_code,dg.city_name,a.cost_nenghao from
  19. (select '202206' as smonth,sname,
  20. sum((column5+column19+column27+column41+column49+column57+column70+column78+column86+column94+column100+column108+column115)-column5-column19-column108) as cost_nenghao
  21. from sqmdb_cost.report50 r
  22. where period_type='M' and stype ='北方省汇总展现'
  23. and sname in ('石家庄_河北','唐山_河北','秦皇岛_河北','邯郸_河北','邢台_河北','保定_河北','张家口_河北','承德_河北','廊坊_河北','沧州_河北','衡水_河北','雄安_河北')
  24. and smonth between '202201' and '202206' group by sname) a
  25. join (select distinct city_code,city_name,city_pro from sqmdb_cost.dict_grid) dg
  26. on a.sname=dg.city_pro) t1
  27. join
  28. (select n2.smonth,n2.city_name,
  29. avg_num(n1.active_onu_num,n2.active_onu_num) as active_onu_num from
  30. (select * from sqmdb_cost.active_onu where smonth='202112') n1
  31. join
  32. (select * from sqmdb_cost.active_onu where smonth='202206') n2
  33. on n1.city_name=n2.city_name) t2
  34. on t1.city_name=t2.city_name
  35. order by t1.city_code