From the course: SQL Essential Training

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Non-aggregate subqueries

Non-aggregate subqueries - SQL Tutorial

From the course: SQL Essential Training

Non-aggregate subqueries

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 sub-query wrapped in a pair of parentheses and then build an outer query around it. Let's go ahead and do that. To make this a sub-query 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 gonna 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 putting our select, let's include the fields invoice date. Let's also include…

Contents