How to Use Simple Subqueries
A simple subquery is a select statement that is contained within an outer select statement. The simple subquery is executed one time and its result is available within the where clause of the outer select.
To learn how to use simple subqueries, follow these steps:
- You'll need to download and install Oracle 12c. The instructions for the setup can be found in How to use sample schemas. Follow steps 1 through 4 in this topic before proceeding to the next step.
- We begin by selecting the employees that earn a salary that is greater than the average salary of the
Employeestable. Execute the following SQL select statement:
Note that I have displayed the first part of the output that contains 51 employees overall. I have highlighted the actual subquery. The subquery is within parentheses and returns the result of the
- Now let's display the employees that earn the maximum salary:
The subquery is enclosed within parentheses and returns the result of the