Can't use derived column name in SQL predicate

I'm not able to use a derived column name in a SQL predicate. For example: SELECT CUST_ID, COUNT(*) AS CNT FROM CUSTOMER_TABLE GROUP BY 1 HAVING CNT > 1 ; ERROR: Column "CNT" does not exist. If I'm using COUNT(*) in the having clause it's working fine.


  • Options
    Hi Pradeep - Thank you for the question. We do not support alias in HAVING clause. Please let me know if you have any questions. Regards, Bhawana

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file