The column reference 'column reference'
is not allowed in this context because it is part of an outer SQL
query expression.
Explanation
The specified column reference is not allowed
because it names a columns of some outer query expression. Such references
are not allowed when contained within the expressions of the HAVING
and SELECT clauses.