23.sql 926 B

123456789101112131415161718192021222324252627282930
  1. --23、铁塔共享率 select * from sqmdb_cost.tower2
  2. ---地市
  3. with t as (select distinct sdate,city_operator,area_operator,site_addr_id,is_duxiang from sqmdb_cost.tower3 where stype in ('新建及共享改造','存量注入'))
  4. select
  5. sdate,
  6. city_operator,
  7. sum(case when is_duxiang='共享' then 1 else 0 end) as share_num,
  8. count(*) as total_num,
  9. sum(case when is_duxiang='共享' then 1 else 0 end)/count(*)::numeric as share_rate
  10. from t
  11. where sdate='202204'
  12. group by sdate,city_operator
  13. ---网格
  14. with t as (select distinct sdate,city_operator,area_operator,site_addr_id,is_duxiang from sqmdb_cost.tower3 where stype in ('新建及共享改造','存量注入'))
  15. select
  16. sdate,
  17. city_operator,
  18. area_operator,
  19. sum(case when is_duxiang='共享' then 1 else 0 end) as share_num,
  20. count(*) as total_num,
  21. sum(case when is_duxiang='共享' then 1 else 0 end)/count(*)::numeric as share_rate
  22. from t
  23. where sdate='202204'
  24. group by sdate,city_operator,area_operator