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!

Column alias error in a query of views

883611Aug 29 2011 — edited Aug 29 2011
Hi
I was trying to workout this query

create view dept_sal as
select d.department_name,sum(e.salary)
from departments d left outer join employees e
on d.department_id= e.department_id
group by d.department_name;

and i recieved this error message .............


Error at Command Line:2 Column:25
Error report:
SQL Error: ORA-00998: must name this expression with a column alias
00998. 00000 - "must name this expression with a column alias"
*Cause:
*Action:


I tried to put an alias for sum(e.salary) function and it worked but i dont understand why it is required or is the problem somewhere else and why an alias is needed here ???

Actually the book hasnt specfied the need for an alias at this place ...so i wanted to know why am getting this error ..

create or replace view dept_sal as
select d.department_name,sum(e.salary) as d_sal
from departments d left outer join employees e
on d.department_id= e.department_id
group by d.department_name;


view DEPT_SAL created.



Also i wanted to know if i can start a thread each time i want have a problem or can i add my questions to somebody
else's thread ..

Thanks
Jayshree
This post has been answered by Hoek on Aug 29 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 26 2011
Added on Aug 29 2011
7 comments
7,566 views