Problem
I need to better understand the rules about when I can reference an outer table in a subquery and when (and why) that is an inappropriate re
How about the following query:
SELECT t1.* FROM ( SELECT * FROM ( SELECT t2.id, RANK() OVER (PARTITION BY t2.id, t2.date ORDER BY t2.date DESC) AS R FROM table2 t2 ) WHERE R = 1 ) sub INNER JOIN table1 t1 ON t1.id = sub.id