Intermediate

Write Complex Subqueries in SQL

subqueries are essential for performing complex filtering, aggregation, and comparisons that go beyond the capabilities of basic SQL JOIN. They allow queries to be nested inside other que...

Before writing complex subqueries, it is crucial to understand the two main types: non-correlated subqueries and correlated subqueries.

A non-correlated subquery is a subquery that executes independently of the main query. It acts as a temporary dataset whose result is calculated once, then reused for each row of the external query.

Conceptual example: Calculate the total number of orders in the system and display this constant value next to each customer.

Sign in to read this course

A free account unlocks all 514 courses. 20 are readable without one.

What's inside

10 sections
  1. 1 Table of Contents
  2. 2 Introduction to complex subqueries
  3. 3 The two basic types of subqueries
  4. 4 Demo: Filtering and comparison with correlated subqueries
  5. 5 Demo: Subqueries in the SELECT clause
  6. 6 Demo: Subqueries in the FROM clause
  7. 7 Demo: Subqueries in the WHERE clause
  8. 8 Comparison of subqueries according to SQL platforms
  9. 9 Key Takeaways
  10. 10 Demo files

Interested in this course?

Contact us to book it or get a custom training plan for your team.