You must put the condition in nr in the HAVING clause, for example:
SELECT c.id, c.name, c.ascii_name, COUNT(*) AS nr
FROM cities c
INNER JOIN jobs j ON (j.city_id = c.id )
WHERE j.is_active = 1
GROUP BY c.name
HAVING nr > 100
limit 100
This is due to the fact that nr is the result of an aggregate function (COUNT (*)) and, as such, is not available when the WHERE filter is applied.
EDIT: on some database servers, the link to nr does not work; you can also use HAVING COUNT(*) > 100.
source
share