Skip to content
Theory · Subqueries · lesson 1 of 11

Scalar subquery

Step 1 writes an avg(price) note for the whole stack, step 2 sends the cards above that line into a tray

Recall the stack of menu cards from the chapter on aggregates. To find the average price, you leaf through the whole stack and write a note: "on average 229.23". Now you can go through the stack once more and set aside the cards that cost more than the number on the note.

In this lesson

  • A query inside a query
  • One value
  • A subquery in SELECT
  • Common mistake
  • Key points