• Okay, so my assumptions were wrong.

    The green office was to the left of the white office." - is that directly to the left (adjacent) or somewhere to the left?

    "Sue has the first office." - is that the leftmost or the rightmost office?

    I've made the assumption that the green and left office need not be directly adjacent, and the the first office is the leftmost office. With those assumptions, there are a total of six solutions to the problem.

    After changing my query to the three other possible combinations of interpretations, I found an interpretation that leaves just one single answer to the question.

    If we assume the the green office is directly adjacent (to the left) if the white office, AND that the first (Sue's) office is to the far right, then my query returns just two rows - and in both rows, Andy is the lucky one who gets to play with the dual 19" LCDs.

    Here's the changed part of the query:

    -- The green office was to the left of the white office.

    AND    CASE 'white'

            WHEN c5.Color THEN 'F'

            WHEN c4.Color THEN CASE WHEN 'green' IN (c5.Color) THEN 'T' ELSE 'F' END

            WHEN c3.Color THEN CASE WHEN 'green' IN (c4.Color) THEN 'T' ELSE 'F' END

            WHEN c2.Color THEN CASE WHEN 'green' IN (c3.Color) THEN 'T' ELSE 'F' END

            WHEN c1.Color THEN CASE WHEN 'green' IN (c2.Color) THEN 'T' ELSE 'F' END

           END = 'T'

    BTW, the execution plan is definitely, ahem, "interesting"


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/