• aaron.reese (6/20/2013)


    Thanks for the explanation guys, I learned something today.

    Actually 2 things. 1) scope and 2) yet another reason not to use subqueries

    Correlated subqueries can be incredibly powerful, they're not something to avoid, just to understand.

    It is a result but I would argue not the correct result. I can't imagine a scenario where you would write the query like that for the result described.

    The query is likely written incorrectly, however the results are correct for the way it's written.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass