-- First we select your data from the ZIP codes table
-- and aggregate or count the total number of records
-- from the NYC 311 data
select
zips.zipcode,
zips.geom,
count(nyc_311.*) as count
-- Then we join the tables on a common ID, in this case the ZIP code
from
nyc_zips zips
join nyc_311 on nyc_311.incident_zip = zips.zipcode
-- Then we filter using WHERE to the right complaint type
-- and group the results by the ZIP code and geometry
where
nyc_311.complaint_type = 'Illegal Parking'
group by
zips.zipcode,
zips.geom