In the picture below, Table 1 and 2 are made up of subqueries full of proprietary fields. I'm trying to figure out the best way to produce the query output on the right but am not sure if I should be writing a boolean statement in the JOIN clause or in the WHERE clause. Even then, I'm not aware of a good CTE or CASE statement that would get the job done.
The only solution I can think of is to take the existing query and convert the whole thing into yet another subquery where I just take the MAX() available History Date by means of a Cartesian Join.
How do I produce the query in the best way?
This post and this post are similar but don't quite get the job done.
