Scalar subqueries are illegal in this context Explanation: Subqueries are illegal in domain constraint definitions and within the FILTER clause for an aggregate. User Action: Do not use subqueries in this context. If necessary call a SQL stored function which can include the subquery.