18_city.sql 997 B

123456789101112131415161718192021222324252627282930
  1. --18、데튄낀무쟁窟쨌郭빱롤(墩)
  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. '18' as ZB_CODE,
  12. '데튄낀무쟁窟쨌郭빱롤(墩)' as ZB_NAME,
  13. '뤠' as IS_RATIO,
  14. t1.cost_xianlu as QZ_FZ,
  15. t2.total_gl as QZ_FM,
  16. t1.cost_xianlu/t2.total_gl/6 as BY_QZ
  17. from
  18. (select '202206' as smonth,sname,
  19. sum(column65+column66+column67+column68+column69)/10000 as cost_xianlu
  20. from sqmdb_cost.report50
  21. where sname in('柯소鏤_붉굇','鉗�_붉굇','해뽈돎_붉굇','벳덱_붉굇','饉憩_붉굇','괏땍_붉굇','蠟소왯_붉굇','넓돠_붉굇','읜렌_붉굇','꾕鹵_붉굇','뷜彊_붉굇','衿갛_붉굇')
  22. and period_type='M' and smonth between '202201' and '202206' group by sname) t1
  23. join
  24. (select city_name||'_붉굇' as city_pro,total_gl
  25. from sqmdb_cost.jt_number_city where month_id='202206') t2
  26. on t1.sname=t2.city_pro
  27. join
  28. (select distinct city_code,city_pro from sqmdb_cost.dict_grid) dg
  29. on t1.sname=dg.city_pro
  30. order by dg.city_code