--24、租赁局站占比 ------------------------使用station3------------------------ ---地市 select '202206' as MONTH_ID, '地市' as ZB_TYPE, '河北' as PROV_NAME, dg.city_code*100 as CITY_ID, a.city_name as CITY_NAME, null as GRID_ID, null as GRID_NAME, '24' as ZB_CODE, '租赁局站占比' as ZB_NAME, '是' as IS_RATIO, zu_num as QZ_FZ, total_num as QZ_FM, zu_rate as BY_QZ from (select city_name, count(*) as total_num, sum(case when property_type like '%租用%' then 1 else 0 end) as zu_num, sum(case when property_type like '%租用%' then 1 else 0 end)/count(*)::numeric as zu_rate from sqmdb_cost.station3 group by city_name) a join (select distinct city_code,city_name from sqmdb_cost.dict_grid) dg on a.city_name=dg.city_name order by dg.city_code