27_grid.sql 820 B

1234567891011121314151617181920212223242526272829
  1. --27、单OLT承载用户数
  2. ---网格
  3. select
  4. a.smonth as MONTH_ID,
  5. '网格' as ZB_TYPE,
  6. '河北' as PROV_NAME,
  7. dcg.city_code*100 as CITY_ID,
  8. dcg.city_name as CITY_NAME,
  9. dcg.grid_code as GRID_ID,
  10. dcg.grid_name as GRID_NAME,
  11. '27' as ZB_CODE,
  12. '单OLT承载用户数' as ZB_NAME,
  13. '否' as IS_RATIO,
  14. a.kd_num as QZ_FZ,
  15. a.olt_num as QZ_FM,
  16. round(a.kd_num/a.olt_num) as BY_QZ
  17. from
  18. (select
  19. ou.smonth,
  20. city_name_short(ou.city_name) as city_name,
  21. dgc.grid_code,
  22. sum(ou.kd_num) as kd_num,
  23. sum(ou.olt_num) as olt_num
  24. from sqmdb_cost.olt_user ou
  25. join sqmdb_cost.dict_grid_code dgc on city_name_short(ou.city_name)=dgc.city_name and trim(ou.area_name)=trim(dgc.grid_name)
  26. where ou.smonth='202206'
  27. group by ou.smonth,city_name_short(ou.city_name),dgc.grid_code) a
  28. join sqmdb_cost.dict_code_grid dcg on a.grid_code=dcg.grid_code
  29. order by dcg.city_code