Skip to main content

Can't use derived column name in SQL predicate

  • June 10, 2013
  • 1 reply
  • 14 views

Pradeep_Dash
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.

1 reply

Bhawana
Forum|alt.badge.img
  • Participating Frequently
  • June 10, 2013
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