I have a query
SELECT COUNT(*) AS \"CNT\", imei FROM devices
which executes just fine. I want to further restrict the query wi
The simple answer is that the AS clause defines what the column will be called in the result, which is a different scope than the query itself.
AS
In your example, using the HAVING clause would work best:
HAVING
SELECT COUNT(*) AS "CNT", imei FROM devices GROUP BY imei HAVING COUNT(*) > 1