I try to write a subquery using SQL in Exasol database. The problem is similar to this thread (SQL Query - join on less than or equal date) and the code works well in mysql and postgres. However, when I move the code to Exasol, it says SQL Error 42000: correlation in on clause. I wonder if there's any alternative solution to this problem or how could i fix it in Exasol?
SELECT a.ID,
a.join_date,
a.country,
a.email,
b.start_date,
b.joined_from
FROM a
LEFT JOIN b
ON a.country = b.country
AND b.start_date = (
SELECT MAX(start_date)
FROM b b2
WHERE b2.country = a.country
AND b2.start_date <= a.join_date
);