09_city.sql 921 B

123456789101112131415161718192021222324252627
  1. --09、百元资产修理维护费
  2. ---地市
  3. select
  4. t1.smonth as MONTH_ID,
  5. '地市' as ZB_TYPE,
  6. '河北' as PROV_NAME,
  7. dg.city_code*100 as CITY_ID,
  8. t1.sname as CITY_NAME,
  9. null as GRID_ID,
  10. null as GRID_NAME,
  11. '9' as ZB_CODE,
  12. '百元资产修理维护费' as ZB_NAME,
  13. '否' as IS_RATIO,
  14. t1.cost_fix as QZ_FZ,
  15. t2.zichan as QZ_FM,
  16. (t1.cost_fix/t2.zichan)*100 as BY_QZ
  17. from
  18. (select smonth,stype,sname,cost_fix from sqmdb_cost.chengben_shengnei where smonth='202206' and stype='地市') t1
  19. join
  20. (select sname,sum(column7+column8)/2 as zichan from sqmdb_cost.report80054 where period_type='M'
  21. and sname in('石家庄_河北','唐山_河北','秦皇岛_河北','邯郸_河北','邢台_河北','保定_河北','张家口_河北','承德_河北','廊坊_河北','沧州_河北','衡水_河北','雄安_河北')
  22. and smonth between '202201' and '202206' group by sname) t2
  23. on t1.sname=t2.sname
  24. join
  25. (select distinct city_code,city_pro from sqmdb_cost.dict_grid) dg
  26. on t1.sname=dg.city_pro
  27. order by dg.city_code