All Products
Document Center

Scalar subquery expressions

Last Updated: Jun 18, 2021

A scalar subquery expression is a subquery that returns a row. This row contains multiple column values. If a subquery returns zero rows, the value of the scalar subquery expression is NULL. If a subquery returns multiple rows, the scalar query expression returns an error. In most expressions, scalar subquery expressions can be used as parameters.

Scalar subqueries are not valid expressions in the following scenarios:

  • As default values of columns

  • In hash functions

  • In the RETURNING clauses of DML statements

  • In the definition of a function index

  • In CHECK constraints

  • In GROUP BY clauses

  • In the statements that are irrelevant to queries, such as CREATE PROFILE