skip to today's puzzle
SQL Sip

A query can hold another query inside it

Put a query inside parentheses and its answer can be used inside a bigger query. The database works out the inner query first, then uses that answer in the outer one. Here the inner query works out the average number of pages, and the outer query keeps the books with more pages than that average.

A tiny example

In plain English: Show me the titles of the books with more pages than the average book.

SELECT title
FROM books
WHERE pages > (
  SELECT AVG(pages)
  FROM books
);

What comes back

title
Dune
East of Eden

These are the two books longer than the average page count the inner query worked out.

Related SQL lessons

Ready for a break?

Take on today's cozy puzzle. A fresh, bite-sized query waits every morning — no timers, no pressure.

play today's sip