Oracle Database 23ai : Group By and Having using Column Aliases
Starting with Oracle Database 23ai, you can use column aliases directly in the GROUP BY and HAVING clauses. This functionality was not available in earlier versions of Oracle Database. Example in Oracle 21c: In Oracle 21c, attempting to use column aliases in the GROUP BY or HAVING clauses would result in an error: Oracle Database 21 c Enterprise Edition Release 21.0 .0 .0 .0 - Production SQL > SELECT LOWER (owner) AS Malek, SUM (bytes / 1024 / 1024 ) AS SIZE_MB 2 FROM dba_segments 3 GROUP BY Malek 4 HAVING SIZE_MB > 100 ; ERROR at line 4 : ORA -00904 : "SIZE_MB": invalid identifier To avoid the invalid identifier error in Oracle 21c, you must rewrite the query without using the alias in the GROUP BY and HAVING clauses: SELECT LOWER (owner) AS Malek, SUM (bytes / 1024 / 1024 ) AS SIZE_MB FROM dba_segments GROUP BY owner HAVING SUM (bytes / 1024...