Sorry, typo again (forgot to install my SQL-checker). The final select should be: select the_geom from zipcodes, (select min(postal_code) as aggr_postal_code, count(*) as total_pop from data group by postal_code ) as aggrdata where zipcodes.postal_code = aggrdata.aggr_postal_code Jan