From the course: SQL Essential Training

Unlock the full course today

Join today to access over 23,100 courses taught by industry experts.

Non-aggregate subqueries

Non-aggregate subqueries - SQL Tutorial

From the course: SQL Essential Training

Non-aggregate subqueries

- [Instructor] A subquery does not always contain an aggregate function as we've been showing previously. If we take a look at the following SQL statement, we will see that the query shows the transaction date for a specific transaction, and that date is January 9th of 2012. Now if we wanted to see if there were any other invoices that were received after the invoice date reference here, we would build a subquery wrapped in a pair of parenthesis and then build an outer query around it. Let's go ahead and do that. To make this a subquery or the inner part of the query, let's go ahead and put some parentheses at the start and all the way at the end of this. Now let's go ahead and build out the rest of our query. I'm going to start above here, and let's go ahead and say from, and we'll say invoice, and let's include what we want to select here. Let's select a few fields from the invoice table. So going above the from and…

Contents