From the course: SQL Essential Training

Unlock the full course today

Join today to access over 22,700 courses taught by industry experts or purchase this course individually.

SELECT clause subquery

SELECT clause subquery - SQL Tutorial

From the course: SQL Essential Training

Start my 1-month free trial

SELECT clause subquery

- [Instructor] To demonstrate the use of subqueries, let's begin with a simple SELECT statement. This is the same SELECT statement we used in our last chapter where we found the average invoice total in the invoice table. We can see that the average invoice value is $8.06. Now, let's say that we were asked by WSDA Music Management to gather data about all invoices that were lower than this average. Well, below here, I've started a partially constructed SQL statement that is going to attempt to respond to this question. Now, we would need a SELECT statement that displays some of the invoice fields such as invoice date, billing address, billing city, and, of course, we need the total. We would then want to filter our results by comparing them to an aggregate function. We would want a WHERE clause that compares the total to the average total. Now, if you recall in our last chapter, we did learn that attempting a direct…

Contents