Postgres Subqueries

Subqueries as Expressions

Scalar Subquery

Results in a single row

Multi-Row Subquery

Results in multiple rows, tipically used in the where clause with operators such as IN, NOT, EXISTS, ANY and ALL.

Correlated Subquery

A uncorrelated sub-query is a type of sub-query where the inner query doesn’t depend upon the outer query for its execution.

Uncorrelated Subquery

A correlated sub-query is a type of query where the inner query depends upon the outcome of the outer query in order to perform its execution.

Subqueries as Tables

References:

Backlinks: