Nested Subqueries in SQL
📖 Scenario: You work at a bookstore that keeps track of books and their sales. You want to find out which books have sold more copies than the average number of copies sold across all books.
🎯 Goal: Build an SQL query using nested subqueries to find the titles of books that sold more copies than the average sales.
📋 What You'll Learn
Create a table called
books with columns id, title, and copies_soldInsert the exact data rows provided into the
books tableWrite a nested subquery to calculate the average copies sold
Use the nested subquery in a WHERE clause to filter books with copies sold greater than the average
💡 Why This Matters
🌍 Real World
Nested subqueries help you compare each row to a calculated value from the whole table, useful in sales analysis, reporting, and decision making.
💼 Career
SQL queries with nested subqueries are common in data analyst and database developer roles to extract meaningful insights from data.
Progress0 / 4 steps