I have a request
SELECT COUNT(*) AS "CNT", imei FROM devices
which runs just fine. I want to further limit the query to the WHERE clause. The next step (humanly) is to modify the request as follows:
SELECT COUNT(*) AS "CNT", imei FROM devices WHERE CNT > 1
However, this results in error message ORA-00904: "CNT": invalid identifier . For some reason, completing a request in another request produces the desired result:
SELECT * FROM (SELECT COUNT(*) AS "CNT", imei FROM devices GROUP BY imei) WHERE CNT > 1
Why doesn't Oracle recognize the alias "CNT" in the second query?
simon source share