Summary

Today, you performed dozens of exercises involving subqueries. By doing this, you have learned how to use one of the most important parts of SQL. The subquery is a method for placing additional conditions on the data returned by your query. A subquery provides great flexibility in defining conditions, especially conditions for which you do not know the exact value. For example, I might want to get a list of all the products priced above average, but I might not know what the overall average price is offhand. I can include a subquery that calculates the average price.

Today, you also tackled one of the most difficult parts of SQL: a correlated subquery. The correlated subquery creates a relationship between the query and the subquery, ...

Get Sams Teach Yourself SQL in 21 Days, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.