• odepriester (9/6/2013)


    GilaMonster (9/6/2013)


    The filter is on the join and it's an outer join. So the filter is done before the join then the left join joins in the matching rows, while also returning any rows that don't match (definition of a left join)

    I thought about 3/4 times about what you said and I hadn't seen in my results that you were right.

    The fields from the description table are NULL when the rows don't match o.type = 'abcd'.

    Summary : I have just discovered a bug in the application :w00t:

    Thx

    You've discovered a small black hole in your understanding of how SQL joins work!

    Jokes aside, the query is fairly straightforward and from your description, is behaving exactly as it should.

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden