Precedence

  • Nice question, thanks.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • good one. It is question on precdence of logical operator. AND has the higer precendence on OR operator. In the first query, the query is as - ModelID = 20 OR (ModelID = 21 AND Color = 'Red')

  • Toreador (7/26/2011)


    Lynn Pettis (7/25/2011)


    The question asked do both of these SELECT statements always return the same number of rows?

    It does now, but didn't originally. The problem with making corrections to questions after they've been published is that people end up arguing based on different questions!

    The email newsletter still had the original question and that is what I read first. Rereading the question on ssc that had been corrected just affirmed my assumption that there was a typo in the original and that my answer was correct for the correct reasons.

    It came down to this, does the use of the parens change the question being answered by the query. The answer is yes either way you read it which means you can easily get different results as data changes (updates, deletes, inserts).

Viewing 3 posts - 46 through 47 (of 47 total)

You must be logged in to reply to this topic. Login to reply