chengben_quzhun_1_b_grid.sql 779 B

123456789101112131415161718192021
  1. ---1-b.铁塔独享站成本占比
  2. ---chengben_quzhun_1_b_grid_202203.csv
  3. ----网格
  4. select
  5. t1.*,
  6. t2.city_code*100 as city_code,
  7. t3.area_code
  8. from
  9. (select sdate,city_operator,area_operator,
  10. sum(total_cost) as cost_total,
  11. sum(case when is_duxiang='独享' then total_cost else 0 end) as cost_du,
  12. sum(case when is_duxiang='独享' then total_cost else 0 end)/sum(total_cost) as cost_du_rate
  13. from sqmdb_cost.tower2 where sdate='202204'
  14. group by sdate,city_operator,area_operator) t1
  15. left join
  16. (select distinct city_code,city_name from sqmdb_cost.dict_grid) t2
  17. on t1.city_operator=t2.city_name
  18. left join
  19. (select distinct city_code,city_name,area_code,area_tower from sqmdb_cost.dict_grid) t3
  20. on t1.city_operator=t3.city_name and t1.area_operator=t3.area_tower
  21. order by t2.city_code,t3.area_code