2025-03-04     2025-03-05     2025-03-06

countries intersecting with shape in cc2

number of errors=1
number of warnings=0

select * from (select geonameid,name,cc2, string_agg(countrycode,',') from (select distinct gp.geonameid,gp.name,gp.cc2,c.countrycode from geoname_shape p, geoname gp, geoname_shape c where c.level=2 and gp.geonameid=p.geonameid and gp.featurecode in ('MTS') and st_intersects (c.wkb_geometry, p.wkb_geometry) order by 1,2) s group by 1,2,3) ss where cc2<>string_agg

geonameid	name	cc2	string_agg	
1252558	Himalayas	BT,CN,IN,NP,PK	BD,BT,CN,IN,NP,PK