Press "Enter" to skip to content

Selecting from the Results of Another Query

Selecting from the Results of Another Query

Problem

You need to treat the results of a query as if they were the contents of a table. You don’t want to store the
intermediate results as you need them freshly generated every time you run your query.

Solution

Oracle’s inline view feature allows a query to be included in the

FROM clause of a statement, with the

results referred to using a table alias.

select d.department_name
from
(select department_id, department_name
from hr.departments
where location_id != 1700) d;

The results will look like this.

DEPARTMENT_NAME
—————-
Marketing
Human Resources
Shipping
IT
Public Relations
Sales

6 rows selected.

One Comment

  1. Anonymous Anonymous November 4, 2012

    thats what i want…

Comments are closed.