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!

Problem with the order by clause and Views

535608Nov 5 2006 — edited Nov 5 2006
I am aware that we cannot use order by while creating views. But I had a problem with order by while retreiving data using views.

I have created a view to list the last names,department names, salaries, salgrades of all the employees with the following syntax:

I have used the following tables: EMPLOYEES, DEPARTMENTS,SALARIES,SALGRADE

CREATE OR REPLACE VIEW salary_vu
AS
SELECT e.last_name "Employee", d.department_name "Department",
e.salary "Salary", s.grade "Grades"
FROM employees e, departments d, salgrade s
WHERE e.department_id = d.department_id
AND e.salary BETWEEN s.losal AND s.hisal;

When I am trying to retreive the data using the following query

select * from salary_vu;

Its working fine.

How can I use order by while retreiving data using views?
for ex: select * from salary_vu order by Employee;

The above stmt gives error, I want to know the correct syntax


Thanks

null
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 3 2006
Added on Nov 5 2006
3 comments
562 views