07.sql 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. --07、百元净资产网运成本
  2. ---北10
  3. select a.smonth,a.sname,
  4. --a.stype,
  5. a.zichan,b.zhejiu,
  6. a.zichan-b.zhejiu as jzc,c.cost_total,
  7. c.cost_total/(a.zichan-b.zhejiu)*100 as jzc_rate
  8. from
  9. (select '202203' as smonth,sname,stype,sum(column7+column8)/2 as zichan
  10. from sqmdb_cost.report80054 where period_type='M' and smonth between '202201' and '202203' group by sname,stype) a
  11. left join
  12. (select '202203' as smonth,sname,stype,sum(column16) as zhejiu
  13. from sqmdb_cost.report80053 where period_type='M' and smonth between '202201' and '202203' group by sname,stype) b
  14. on a.smonth=b.smonth and a.sname=b.sname and a.stype=b.stype
  15. left join
  16. (select '202203' as smonth,sname,stype,sum(column1)/10000 as cost_total
  17. from sqmdb_cost.report50 where smonth between '202201' and '202203' group by sname,stype) c
  18. on a.smonth=c.smonth and a.sname=c.sname and a.stype=c.stype
  19. where a.sname in('北京','天津','河北','山西','内蒙古','辽宁','吉林','黑龙江','山东','河南')
  20. ---地市
  21. select a.smonth,a.sname,
  22. --a.stype,
  23. a.zichan,b.zhejiu,
  24. a.zichan-b.zhejiu as jzc,c.cost_total,
  25. c.cost_total/(a.zichan-b.zhejiu)*100 as jzc_rate
  26. from
  27. (select '202203' as smonth,sname,stype,sum(column7+column8)/2 as zichan
  28. from sqmdb_cost.report80054 where period_type='M' and smonth between '202201' and '202203' group by sname,stype) a
  29. left join
  30. (select '202203' as smonth,sname,stype,sum(column16) as zhejiu
  31. from sqmdb_cost.report80053 where period_type='M' and smonth between '202201' and '202203' group by sname,stype) b
  32. on a.smonth=b.smonth and a.sname=b.sname and a.stype=b.stype
  33. left join
  34. (select '202203' as smonth,sname,stype,sum(column1)/10000 as cost_total
  35. from sqmdb_cost.report50 where smonth between '202201' and '202203' group by sname,stype) c
  36. on a.smonth=c.smonth and a.sname=c.sname
  37. where a.sname in('石家庄_河北','唐山_河北','秦皇岛_河北','邯郸_河北','邢台_河北','保定_河北','张家口_河北','承德_河北','廊坊_河北','沧州_河北','衡水_河北','雄安_河北')