11_city.sql 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. --11、单业务量移网成本
  2. ---地市
  3. select
  4. cost_t.smonth as MONTH_ID,
  5. '地市' as ZB_TYPE,
  6. '河北' as PROV_NAME,
  7. cost_t.city_code*100 as CITY_ID,
  8. cost_t.city_name as CITY_NAME,
  9. null as GRID_ID,
  10. null as GRID_NAME,
  11. '11' as ZB_CODE,
  12. '单业务量移网成本' as ZB_NAME,
  13. '否' as IS_RATIO,
  14. cost_t.cost_yw+cost_t.cost_hexin as QZ_FZ,
  15. ywl_t.yewul as QZ_FM,
  16. (cost_t.cost_yw+cost_t.cost_hexin)/ywl_t.yewul/7 as BY_QZ
  17. from
  18. (select a.smonth,dg.city_name,dg.city_code,a.cost_yw,a.cost_hexin from
  19. (select '202207' as smonth,sname,
  20. sum(column2+column3+column4+column5+column6+column7+column8+column9+column10+column11+column12+column13+column14+column15+column16+column17+column18) as cost_yw,
  21. sum(column19+column20+column21+column22+column23+column24+column25+column26) as cost_hexin
  22. from sqmdb_cost.report50
  23. where period_type='M'
  24. and sname in('石家庄_河北','唐山_河北','秦皇岛_河北','邯郸_河北','邢台_河北','保定_河北','张家口_河北','承德_河北','廊坊_河北','沧州_河北','衡水_河北','雄安_河北')
  25. and smonth between '202201' and '202207' group by sname) a
  26. join (select distinct city_code,city_pro,city_name from sqmdb_cost.dict_grid) dg
  27. on a.sname=dg.city_pro) cost_t
  28. join
  29. (select dg.city_name,avg_num(y1.yewul,y2.yewul) as yewul from
  30. (select city_name,sum(yewul) as yewul from sqmdb_cost.zpzs z where grid_name!='合计' and smonth='202112' group by city_name) y1
  31. join
  32. (select city_name,sum(yewul) as yewul from sqmdb_cost.zpzs z where grid_name!='合计' and smonth='202207' group by city_name) y2
  33. on y1.city_name=y2.city_name
  34. join
  35. (select distinct city_sname,city_code,city_name from sqmdb_cost.dict_grid) dg
  36. on y1.city_name=dg.city_sname) ywl_t
  37. on cost_t.city_name=ywl_t.city_name
  38. order by cost_t.city_code