• A good question - the sort of thing I would like to see more of because it's about understanding the system and its language rather than about remembering the reference book. But unfotunately it's even more about ability to read and understand code which is obfuscated by really terrible formatting than about understanding nested joins. I was glad to see in your reply to an earlier comment that the appalling format was deliberate, not something that you thought was good format (and hope that applies to the query that was the correct answer too, despite its having only nesting implied by L to R semantics; I would still insist on using indentation to indicate the structure including nesting of the pair of joins in that query, since I don't see it as structurally an different from the original query).

    It's another one where I'm surprised by the failure rate - 78% wrong answers is amazing. Does that mean that 78% of people here never write or read complex queries?

    My first approach to this was to format all five queries sensibly, but as I don't possess a decent automatic formatter I decided to do some elimination first so that I'd only have to format some - and what with a query that would have no nulls introduced by the outer join, another that would eliminate all rows that missed on what was supposed to be a potentially null-introducing outer join condition, and another that could allow one null (or none, or two) to be introduced by the outer join while the original query could only introduce none or two I quickly discovered that I didn't have to do any formatting to get the answer becaue I'd eliminated all but one of the options. I didn't check the other option thoroughly, just checked that moving one particular condition to the inner join to the outer join would have no effect, and that was it. So not too much effort - but I still think any code formatted like that should earn a written warning to the writer, and a repeat performance a dismissal, even though I could quite quickly get the answer without sorting out the format in this case.

    Tom