Subquery

noun

say it: “SUB-kweer-ee” /ˈsʌbkwɪəri/

A query written inside another query, in parentheses.

What is Subquery in a relational database?

Subquery — A query nested inside another SQL statement.

SELECT order_id
FROM purchase_order
WHERE total_amount > (
    SELECT AVG(total_amount)
    FROM purchase_order
);

In a sentence

  • “A subquery found the average price, and the outer query kept products above it.”

Level: Apprentice · More SQL terms at this level

Updated