Using column aliases in having clause error
931541Apr 18 2012 — edited Apr 18 2012This is the query I'm trying to run.
select concat(concat(student.last_name, ', '), student.first_name) student, count(school_apply.decision) decision
from student, school_apply
where student.student_id = school_apply.student_id
and school_apply.decision = 'accepted'
having decision < 3
group by student.last_name, student.first_name
order by count(school_apply.decision) desc, student.last_name, student.first_name;
I got the following error
Error at Command Line:5 Column:7
Error report:
SQL Error: ORA-00979: not a GROUP BY expression
00979. 00000 - "not a GROUP BY expression"
if in the having I use count(school_apply.decision) instead of the alias, it works fine. Why is this? and how can I use the alias'd column in the SQL?