06.sql 1017 B

123456789101112131415161718192021222324252627
  1. --06、百元资产网运成本(省内口径)
  2. ---北10
  3. select a.smonth,a.sname,a.cost_total,b.zichan,
  4. a.cost_total/b.zichan*100 as cost_bai
  5. from
  6. (select smonth,stype,sname,cost_total as cost_total from sqmdb_cost.chengben_shengnei
  7. where stype='北10'
  8. and smonth='202203') a
  9. join
  10. (select smonth,sname,stype,(column7+column8)/2 as zichan from sqmdb_cost.report80054
  11. where sname in('北京','天津','河北','山西','内蒙古','辽宁','吉林','黑龙江','山东','河南')
  12. and stype='分省展现'
  13. and smonth='202203') b
  14. on a.sname=b.sname
  15. ---地市
  16. select a.smonth,a.sname,a.cost_total,b.zichan,
  17. a.cost_total/b.zichan*100 as cost_bai
  18. from
  19. (select smonth,stype,sname,cost_total from sqmdb_cost.chengben_shengnei
  20. where stype='地市'
  21. and smonth='202203') a
  22. join
  23. (select smonth,sname,stype,(column7+column8)/2 as zichan from sqmdb_cost.report80054
  24. where sname in('石家庄_河北','唐山_河北','秦皇岛_河北','邯郸_河北','邢台_河北','保定_河北','张家口_河北','承德_河北','廊坊_河北','沧州_河北','衡水_河北','雄安_河北')
  25. and smonth='202203') b
  26. on a.sname=b.sname