大屏_比自己.sql 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. --预算进度
  2. --chengben_self_1_b10_202203.csv
  3. --03、网运成本预算完成进度(集团口径)
  4. ---北10
  5. select smonth,sname,
  6. column1 as total_cost,
  7. column2 as total_ys,
  8. case when column2=0 then 1 else column1/column2 end as rate_ys,
  9. case
  10. when sname='北京' then 110000
  11. when sname='天津' then 120000
  12. when sname='河北' then 130000
  13. when sname='山西' then 140000
  14. when sname='内蒙古' then 150000
  15. when sname='辽宁' then 210000
  16. when sname='吉林' then 220000
  17. when sname='黑龙江' then 230000
  18. when sname='山东' then 370000
  19. when sname='河南' then 410000
  20. end as prov_code
  21. from sqmdb_cost.report50002
  22. where sname in('北京','天津','河北','山西','内蒙古','辽宁','吉林','黑龙江','山东','河南')
  23. and smonth='202203'
  24. order by case
  25. when sname='北京' then 1
  26. when sname='天津' then 2
  27. when sname='河北' then 3
  28. when sname='山西' then 4
  29. when sname='内蒙古' then 5
  30. when sname='辽宁' then 6
  31. when sname='吉林' then 7
  32. when sname='黑龙江' then 8
  33. when sname='山东' then 9
  34. when sname='河南' then 10
  35. end
  36. --主要成本(万元)
  37. --chengben_self_2_city_202203.csv
  38. ---地市
  39. select
  40. jt.*,
  41. sn.cost_total_sn,
  42. t2.city_code*100 as city_code
  43. from
  44. (select
  45. a.smonth,
  46. a.sname,
  47. a.cost_total_jt,
  48. a.cost_rental_tower_jt,
  49. a.cost_nenghao_jt,
  50. a.cost_rental_3rd_jt
  51. from
  52. (select smonth,sname,stype,
  53. column1/10000 as cost_total_jt,
  54. (column5+column19+column27+column41+column49+column57+column70+column78+column86+column94+column100+column108+column115+column4)/10000 as cost_nenghao_jt,
  55. (column12+column15+column16)/10000 as cost_rental_3rd_jt,
  56. (column2+column3)/10000 as cost_rental_tower_jt
  57. from sqmdb_cost.report50 where stype ='北方省汇总展现') a
  58. left join
  59. (select report_id,smonth,sname,stype,column4 as income_year from sqmdb_cost.report80040) b
  60. on a.smonth=b.smonth and a.sname=b.sname
  61. where
  62. a.sname in ('石家庄_河北','唐山_河北','秦皇岛_河北','邯郸_河北','邢台_河北','保定_河北','张家口_河北','承德_河北','廊坊_河北','沧州_河北','衡水_河北','雄安_河北')) jt
  63. left join
  64. (select smonth,sname,cost_total as cost_total_sn from sqmdb_cost.chengben_shengnei where stype='地市') sn
  65. on jt.smonth=sn.smonth and jt.sname=sn.sname
  66. left join
  67. (select distinct city_code,city_pro from sqmdb_cost.dict_grid) t2
  68. on jt.sname=t2.city_pro
  69. where jt.smonth='202203'
  70. order by t2.city_code
  71. ---网格(无分母)