-7058: Correlated subquery with select in from clause not allowed

Explanation:

You are not allowed to include a QUERY expression in the FROM clause of a correlated subquery.

User Action:

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.