15.sql 832 B

123456789101112131415161718192021
  1. --15、活动ONU单端口能耗(月)
  2. ---地市
  3. select
  4. t1.smonth,
  5. t1.city_name,
  6. t1.cost_nenghao/10000 as cost_nenghao,
  7. t2.active_onu_num/10000 as active_onu_num,
  8. t1.cost_nenghao/t2.active_onu_num as cost_onu
  9. from
  10. (select distinct a.smonth,dg.city_name,a.cost_nenghao from
  11. (select smonth,sname,stype,
  12. (column5+column19+column27+column41+column49+column57+column70+column78+column86+column94+column100+column108+column115)-column5-column19-column108 as cost_nenghao
  13. from sqmdb_cost.report50 r
  14. where stype ='北方省汇总展现'
  15. and sname in ('石家庄_河北','唐山_河北','秦皇岛_河北','邯郸_河北','邢台_河北','保定_河北','张家口_河北','承德_河北','廊坊_河北','沧州_河北','衡水_河北','雄安_河北')
  16. and smonth='202203') a
  17. join sqmdb_cost.dict_grid dg
  18. on a.sname=dg.city_pro) t1
  19. join
  20. (select * from sqmdb_cost.active_onu) t2
  21. on t1.city_name=t2.city_name