scalar subquery
A subquery that returns exactly one value, one row and one column, so it can be used wherever a single value can.
In more detail
WHERE price_cents > (SELECT AVG(price_cents) FROM products) compares each product with the overall average. If it returns no rows the value is NULL.
Related terms
- subquery — A query written in brackets inside another query, whose result the outer query uses.
- AVG — An aggregate that returns the arithmetic mean of the non-NULL values in a group.
Taught in
- Subqueries — PostgreSQL, Indexing & Relational Data Modeling