24_city.sql 744 B

12345678910111213141516171819202122232425262728
  1. --24、租赁局站占比
  2. ------------------------使用station3------------------------
  3. ---地市
  4. select
  5. '202206' as MONTH_ID,
  6. '地市' as ZB_TYPE,
  7. '河北' as PROV_NAME,
  8. dg.city_code*100 as CITY_ID,
  9. a.city_name as CITY_NAME,
  10. null as GRID_ID,
  11. null as GRID_NAME,
  12. '24' as ZB_CODE,
  13. '租赁局站占比' as ZB_NAME,
  14. '是' as IS_RATIO,
  15. zu_num as QZ_FZ,
  16. total_num as QZ_FM,
  17. zu_rate as BY_QZ
  18. from
  19. (select city_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) a
  25. join
  26. (select distinct city_code,city_name from sqmdb_cost.dict_grid) dg
  27. on a.city_name=dg.city_name
  28. order by dg.city_code