Chris, your question has kept me bussy for at least 2 hours two nights ago, however I can not give you any usefull advice, only some of my observations.
First of all, you are wrong at saying "This *should* work" - it *can't* work. The reason is not in 2-levels of nesting as you assume, the reason is in the fact that you are trying to reference outer query's column from the *inline view*.
In your second example (the one that is working) you are referencing an outer query from sub-select that is positioned in the "column list " part of the query (between SELECT and FROM) of the outer query. This is perfectly legal and logical. But in your initial example (the one that is not working) you are trying to reference an outer query from an inline view query, that is the sub-query in the FROM clause. Now that is not permited, you can never reference an outer query's column from an inline view. Never. The fact that your inline view lies inside a sub-select in your "column list" does not change that fact.
So I gues you won't be able to overcome this without actually rewriting your query. But I must say your logic in this attempt was realy impressive - if it would have worked it would be an exceptional solution, definitelly much more efficient than any other solution. However those "other sollutions" at least work....
Jurij Modic
ASCII a stupid question, get a stupid ANSI
24 hours in a day .... 24 beer in a case .... coincidence?