chengben_self_2_city.sql 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. --主要成本(万元)
  2. --chengben_self_2_city_202203.csv
  3. ---地市
  4. select
  5. jt.*,
  6. sn.cost_total_sn,
  7. sn.cost_fix_sn,
  8. t2.city_code*100 as city_code
  9. from
  10. (select
  11. a.smonth,
  12. a.sname,
  13. a.cost_total_jt,
  14. a.cost_rental_tower_jt,
  15. a.cost_nenghao_jt,
  16. a.cost_rental_3rd_jt
  17. from
  18. (select '202204' as smonth,sname,stype,
  19. sum(column1)/10000 as cost_total_jt,
  20. sum(column5+column19+column27+column41+column49+column57+column70+column78+column86+column94+column100+column108+column115)/10000 as cost_nenghao_jt,
  21. sum(column12+column15+column16)/10000 as cost_rental_3rd_jt,
  22. sum(column2+column3)/10000 as cost_rental_tower_jt
  23. from sqmdb_cost.report50 where period_type='M' and stype ='北方省汇总展现'
  24. and smonth between '202201' and '202204' group by sname,stype) a
  25. left join
  26. (select report_id,smonth,sname,stype,column4 as income_year from sqmdb_cost.report80040) b
  27. on a.smonth=b.smonth and a.sname=b.sname
  28. where
  29. a.sname in ('石家庄_河北','唐山_河北','秦皇岛_河北','邯郸_河北','邢台_河北','保定_河北','张家口_河北','承德_河北','廊坊_河北','沧州_河北','衡水_河北','雄安_河北')) jt
  30. left join
  31. (select smonth,sname,cost_total as cost_total_sn,cost_fix as cost_fix_sn from sqmdb_cost.chengben_shengnei where stype='地市') sn
  32. on jt.smonth=sn.smonth and jt.sname=sn.sname
  33. left join
  34. (select distinct city_code,city_pro from sqmdb_cost.dict_grid) t2
  35. on jt.sname=t2.city_pro
  36. where jt.smonth='202204'
  37. order by t2.city_code