19_b10.sql 949 B

123456789101112131415161718192021222324
  1. --19、无线成本占收比
  2. ---北10
  3. select
  4. a.smonth as MONTH_ID,
  5. '北10' as ZB_TYPE,
  6. a.sname as PROV_NAME,
  7. null as CITY_ID,
  8. null as CITY_NAME,
  9. null as GRID_ID,
  10. null as GRID_NAME,
  11. '19' as ZB_CODE,
  12. '无线成本占收比' as ZB_NAME,
  13. '是' as IS_RATIO,
  14. a.cost_wireless as QZ_FZ,
  15. b.income_year as QZ_FM,
  16. case when b.income_year=0 then null else a.cost_wireless/b.income_year end as BY_QZ
  17. from
  18. (select '202206' as smonth,sname,stype,
  19. sum(column2+column3+column4+column5+column6+column7+column8+column9+column10+column11+column12+column13+column14+column15+column16+column17)/10000 as cost_wireless --column18 账面人工成本
  20. from sqmdb_cost.report50 where period_type='M' and smonth between '202201' and '202206' group by sname,stype) a
  21. left join
  22. (select report_id,smonth,sname,stype,column4 as income_year from sqmdb_cost.report80040 where smonth='202206') b
  23. on a.sname=b.sname
  24. where a.sname in('北京','天津','河北','山西','内蒙古','辽宁','吉林','黑龙江','山东','河南')