17_city.sql 798 B

1234567891011121314151617181920212223242526272829
  1. --17、户均装机料费
  2. ---地市
  3. select
  4. fz.smonth as MONTH_ID,
  5. '地市' as ZB_TYPE,
  6. '河北' as PROV_NAME,
  7. fm.city_code*100 as CITY_ID,
  8. fz.sname as CITY_NAME,
  9. null as GRID_ID,
  10. null as GRID_NAME,
  11. '17' as ZB_CODE,
  12. '户均装机料费' as ZB_NAME,
  13. '否' as IS_RATIO,
  14. fz.cost_liao as QZ_FZ,
  15. fm.order_num as QZ_FM,
  16. fz.cost_liao/fm.order_num/6 as BY_QZ
  17. from
  18. (select smonth,sname,cost_liao from sqmdb_cost.chengben_shengnei cs
  19. where stype='地市' and smonth='202206') fz
  20. join
  21. (select b.city_code,b.city_pro,a.order_num from
  22. (select smonth,city_name,sum(order_num)/10000 as order_num
  23. from sqmdb_cost.zhuangji z where smonth='202206'
  24. group by smonth,city_name) a
  25. join
  26. (select distinct city_code,city_name,city_pro from sqmdb_cost.dict_grid dg) b
  27. on a.city_name=b.city_name) fm
  28. on fz.sname=fm.city_pro
  29. order by fm.city_code