Subquery restrictions
To construct queries efficiently, you must understand the restrictions of subqueries in WHERE clauses.
-
Subqueries must appear on the right side of an expression.
-
Nested subqueries are not supported.
-
Subquery predicates must appear as top-level conjuncts.
-
Subqueries support four logical operators in query predicates: IN, NOT IN, EXISTS, and NOT EXISTS.
-
The IN and NOT IN logical operators may select only one column in a WHERE clause subquery.
-
The EXISTS and NOT EXISTS operators must have at least one correlated predicate.
-
The left side of a subquery must qualify all references to table columns.
-
References to columns in the parent query are allowed only in the WHERE clause of the subquery.
-
Subquery predicates that reference a column in a parent query must use the equals (=) predicate operator.
-
Subquery predicates may refer only to columns in the parent query.
-
Correlated subqueries with an implied GROUP BY statement may return only one row.
-
All unqualified references to columns in a subquery must resolve to tables in the subquery.
-
Correlated subqueries cannot contain windowing clauses.