How To Use Subqueries in the FROM clause in Oracle?
Submitted by: AdministratorIf you have a query returning many rows of data, and you want to perform another query on those rows, you can put the first query as a subquery in the FROM clause of the second query. The following statement shows you how to use a subquery as base table for the main query:
SQL> SELECT * FROM (
2 SELECT first_name, last_name, department_name
3 FROM employees e, departments d
4 WHERE e.department_id = d.department_id
5 ) WHERE department_name LIKE 'S%' ORDER BY last_name;
<pre>FIRST_NAME LAST_NAME DEPARTMENT_NAME
----------------- ---------------------- ---------------
Ellen Abel Sales
Sundar Ande Sales
Mozhe Atkinson Shipping
Amit Banda Sales
Elizabeth Bates Sales
Sarah Bell Shipping</pre>
Submitted by: Administrator
SQL> SELECT * FROM (
2 SELECT first_name, last_name, department_name
3 FROM employees e, departments d
4 WHERE e.department_id = d.department_id
5 ) WHERE department_name LIKE 'S%' ORDER BY last_name;
<pre>FIRST_NAME LAST_NAME DEPARTMENT_NAME
----------------- ---------------------- ---------------
Ellen Abel Sales
Sundar Ande Sales
Mozhe Atkinson Shipping
Amit Banda Sales
Elizabeth Bates Sales
Sarah Bell Shipping</pre>
Submitted by: Administrator
Read Online Oracle Database Job Interview Questions And Answers
Top Oracle Database Questions
☺ | What Happens to Indexes If You Drop a Table? |
☺ | How To Define a Data Field as NOT NULL? |
☺ | How To Create a Stored Procedure in Oracle? |
☺ | How To Check Your Oracle Database 10g XE Installation? |
☺ | What Is the Relation of a User Account and a Schema? |
Top DB Oracle Categories
☺ | Oracle PL-SQL Interview Questions. |
☺ | Oracle DBA Interview Questions. |
☺ | Oracle D2K Interview Questions. |
☺ | OCI Interview Questions. |
☺ | Forms Reports Interview Questions. |