Building and Organizing Complex Queries
In the third lesson of this SQL Intermediate course, you'll focus on how to build and organize more complex queries to increase your knowledge of SQL and add more tools to your toolbox. You’ll also learn more about formatting and SQL best practices so that you can make your queries more readable for others (or for yourself in the future).
You'll learn about the `WITH` clause to create CTEs along with `CREATE VIEW` to organize your queries. You will also learn how to use set operations such as `UNION`, `UNION ALL`, `INTERSECT`, and `EXCEPT` to combine results from two tables that have no column relation.
Of course, you’ll get hands-on practice using and applying each of these concepts, as well as practicing the SQL concepts you’ve learned in previous lessons.
To facilitate your building and organizing complex queries, you'll be working with the Chinook database, a music collection database that includes song details like track name, album name, artist name, genre, and the number of tracks purchased.
2. Writing Readable Queries
3. The With Clause
4. Creating Views
5. Combining Rows With Union
6. Combining Rows Using Intersect and Except
7. Multiple Named Subqueries
8. Challenge: Each Country's Best Customer
9. Next Steps