Explanation
You are not allowed to include a QUERY expression in the FROM clause of a correlated subquery.
User Response
Formulate the corresponding subquery to leave out the QUERY expression. If this is not possible, split the SQL statement into at least two SQL statements and generate a named result table that can be used in the FROM clause.