select substr(zip,1,2) plz, count(*) from job_data_main where cat2 = "painter" and timestamp >= "2015-10-01" group by plz; select substr(zip,1,2) plz,count(*) from wrk_notif w, usr_client uc where uc.id = w.userid and uc.lastlogin >= date_sub(curdate(),interval 1 month) and w.notify = "yes" and w.cats like "%painter%" group by plz;