01_city.sql 1008 B

123456789101112131415161718192021222324252627
  1. select
  2. '202207' as MONTH_ID,
  3. '地市' as ZB_TYPE,
  4. '河北' as PROV_NAME,
  5. c.city_code*100 as CITY_ID,
  6. a.sname as CITY_NAME,
  7. null as GRID_ID,
  8. null as GRID_NAME,
  9. '1' as ZB_CODE,
  10. '网运成本占收比(集团口径)' as ZB_NAME,
  11. '是' as IS_RATIO,
  12. a.cost_total as QZ_FZ,
  13. b.income_year as QZ_FM,--本年收入累计,
  14. case when b.income_year=0 then null else a.cost_total/b.income_year end as BY_QZ
  15. from
  16. (select sname,
  17. sum(column1)/10000 as cost_total--成本合计(包含人工)
  18. from sqmdb_cost.report50 where period_type='M' and smonth between '202201' and '202207' group by sname) a
  19. left join
  20. (select report_id,smonth,sname,stype,column4 as income_year from sqmdb_cost.report80040
  21. where period_type='M' and smonth='202207') b
  22. on a.sname=b.sname
  23. left join
  24. (select distinct city_code,city_pro from sqmdb_cost.dict_grid) c
  25. on a.sname=c.city_pro
  26. where a.sname in ('石家庄_河北','唐山_河北','秦皇岛_河北','邯郸_河北','邢台_河北','保定_河北','张家口_河北','承德_河北','廊坊_河北','沧州_河北','衡水_河北','雄安_河北')
  27. order by c.city_code