Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using column aliases in having clause error

931541Apr 18 2012 — edited Apr 18 2012
This 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?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 16 2012
Added on Apr 18 2012
1 comment
5,289 views