26_grid.sql 1.0 KB

12345678910111213141516171819202122232425262728
  1. --26、H端口实占率
  2. ---网格
  3. select
  4. '202206' 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. a.area_name as GRID_NAME,
  11. '26' as ZB_CODE,
  12. 'H端口实占率' as ZB_NAME,
  13. '是' as IS_RATIO,
  14. a.ftth_port_sts_count as QZ_FZ,
  15. a.ftth_port_count as QZ_FM,
  16. case when a.ftth_port_count=0 then 0 else a.ftth_port_sts_count/a.ftth_port_count end as BY_QZ
  17. from
  18. (select p2.smonth,p2.city_name,p2.area_name,
  19. avg_num(p1.ftth_port_sts_count,p2.ftth_port_sts_count)/10000 as ftth_port_sts_count,
  20. avg_num(p1.ftth_port_count,p2.ftth_port_count)/10000 as ftth_port_count
  21. from
  22. (select * from sqmdb_cost.kuandai_ftth_month where smonth='202112')p1
  23. join
  24. (select * from sqmdb_cost.kuandai_ftth_month where smonth='202206')p2
  25. on p1.city_name=p2.city_name and p1.area_name=p2.area_name) a
  26. left join sqmdb_cost.dict_grid_code dgc on a.city_name=dgc.city_name and trim(a.area_name)=trim(dgc.grid_name)
  27. join sqmdb_cost.dict_code_grid dcg on dgc.grid_code=dcg.grid_code
  28. order by dcg.city_code