When writing correlated sub-queries in BigQuery using a WHERE clause, it is resulting in an Error. LEFT OUTER JOIN cannot be used without a condition that is an equality of fields from both sides of the join.
However it works in other SQL engines, I am not understanding the error or how to rewrite the queries.
Different queries of the same type causing the same error.
SELECT
out.*
FROM
`august-monolith-205810.Assignment.students` AS out
WHERE
2 >= (
SELECT
COUNT(*)
FROM
`august-monolith-205810.Assignment.students` AS t1
WHERE
out.age < t1.age)
reporting students who are older than at most two other students.
SELECT * FROM (SELECT ..., ROW_NUMBER() OVER(ORDER BY age) AS row_number) AS alias WHERE alias.row_number >= 2
which is believe should give the same results as your co-related subquery because you simulate or emulate a rank or row_number with you co-related subquery. – Raymond Nijland