24_grid.sql 878 B

123456789101112131415161718192021222324252627
  1. --24、租赁局站占比
  2. ------------------------使用station3------------------------
  3. ---网格
  4. select
  5. '202206' as MONTH_ID,
  6. '网格' as ZB_TYPE,
  7. '河北' as PROV_NAME,
  8. dcg.city_code*100 as CITY_ID,
  9. dcg.city_name as CITY_NAME,
  10. dcg.grid_code as GRID_ID,
  11. a.area_name as GRID_NAME,
  12. '24' as ZB_CODE,
  13. '租赁局站占比' as ZB_NAME,
  14. '是' as IS_RATIO,
  15. a.zu_num as QZ_FZ,
  16. a.total_num as QZ_FM,
  17. a.zu_rate as BY_QZ
  18. from
  19. (select city_name,area_name,
  20. count(*) as total_num,
  21. sum(case when property_type like '%租用%' then 1 else 0 end) as zu_num,
  22. sum(case when property_type like '%租用%' then 1 else 0 end)/count(*)::numeric as zu_rate
  23. from sqmdb_cost.station3
  24. group by city_name,area_name) a
  25. join sqmdb_cost.dict_grid_code dgc on city_name_short(a.city_name)=dgc.city_name and trim(a.area_name)=trim(dgc.grid_name)
  26. join sqmdb_cost.dict_code_grid dcg on dgc.grid_code=dcg.grid_code
  27. order by dcg.city_code