Oracle PL/SQL won’t let users to use aliases in conditions. In most cases it’s very practical for me to use aliases instead of long statements. What’s the reason for that? What bad would happen if we could use aliases in conditions?
Example case: What's wrong with this SQL query?
I think it’s just because that is what the SQL standard specifies. I don’t agree with gd047 that the alias couldn’t be used: the HAVING clause operates on the (intermediate) results of the query i.e. after aggregation, so it would seem pretty straight-forward for the query parser to use the alias to access that result.
You can of course avoid repeating the SUM like this (using the example from the linked question):