Subquery

Noun · Development

Definitions

  1. A SQL query nested inside another query, typically within a WHERE, FROM, or SELECT clause. The inner query executes first and its result is used by the outer query — for example, finding all orders whose total exceeds the average: `WHERE total > (SELECT AVG(total) FROM orders)`.

    In plain English: A query inside another query, where the inner one calculates a result that the outer one uses as part of its own filter or data source.

    Example: "The subquery pulls the latest price per SKU, then the outer query joins it to the order lines."

Related Terms