27_city.sql 642 B

1234567891011121314151617181920212223
  1. --27、单OLT承载用户数
  2. ---地市
  3. with grid as (select ou.smonth,dg.city_code,ou.city_name,ou.area_name,kd_num,olt_num from sqmdb_cost.olt_user ou
  4. join
  5. (select distinct city_code,city_name from sqmdb_cost.dict_grid) dg
  6. on ou.city_name=dg.city_name
  7. where ou.smonth='202206')
  8. select
  9. smonth as MONTH_ID,
  10. '地市' as ZB_TYPE,
  11. '河北' as PROV_NAME,
  12. city_code*100 as CITY_ID,
  13. city_name as CITY_NAME,
  14. null as GRID_ID,
  15. null as GRID_NAME,
  16. '27' as ZB_CODE,
  17. '单OLT承载用户数' as ZB_NAME,
  18. '否' as IS_RATIO,
  19. sum(kd_num) as QZ_FZ,
  20. sum(olt_num) as QZ_FM,
  21. round(sum(kd_num)/sum(olt_num)) as BY_QZ
  22. from grid group by smonth,city_code,city_name
  23. order by city_code