23_city.sql 899 B

1234567891011121314151617181920212223242526272829
  1. --23、铁塔共享率 select * from sqmdb_cost.tower3
  2. ---地市
  3. select
  4. a.sdate as MONTH_ID,
  5. '地市' as ZB_TYPE,
  6. '河北' as PROV_NAME,
  7. dg.city_code*100 as CITY_ID,
  8. a.city_operator as CITY_NAME,
  9. null as GRID_ID,
  10. null as GRID_NAME,
  11. '23' as ZB_CODE,
  12. '铁塔共享率' as ZB_NAME,
  13. '是' as IS_RATIO,
  14. a.share_num as QZ_FZ,
  15. a.total_num as QZ_FM,
  16. a.share_rate as BY_QZ
  17. from
  18. (with t as (select distinct sdate,city_operator,area_operator,site_addr_id,is_duxiang from sqmdb_cost.tower3 where stype in ('新建及共享改造','存量注入'))
  19. select sdate,city_operator,
  20. sum(case when is_duxiang='共享' then 1 else 0 end) as share_num,
  21. count(*) as total_num,
  22. sum(case when is_duxiang='共享' then 1 else 0 end)/count(*)::numeric as share_rate
  23. from t
  24. where sdate='202207'
  25. group by sdate,city_operator) a
  26. left join
  27. (select distinct city_code,city_name from sqmdb_cost.dict_grid) dg
  28. on a.city_operator=dg.city_name
  29. order by dg.city_code