From the course: Oracle Database 12c: Advanced SQL
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Using single-value subqueries - Oracle Database Tutorial
From the course: Oracle Database 12c: Advanced SQL
Using single-value subqueries
- [Instructor] As we saw in our previous video subqueries allows you to write SQL queries that select data, for a criteria, that is developed during query run-time, that is as the query itself is executing. For example, we can use a subquery in the WHERE clause of another sequel query. Instead of having to explicitly specify the values we wish to filter on. A subquery can be executed, testing these values to the external or encompassing query. Let's start with a simple example. Selecting the details for the employee earning the highest salary in our company. So I'll type select max salary from employees. We can now use this query as a subquery in another query. So I'll type select star, from employees, where salary equals, and then instead of specifying a literal string, inside parenthesis I can just contain my subquery. So what will happen is that the Oracle database will first execute the subquery, return the result of the subquery, which is $24,000, and then this value will…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.