Logical Operators

  • Comments posted to this topic are about the item Logical Operators

    :exclamation: "Be brave. Take risks. Nothing can substitute experience." :exclamation:

  • Nice question, thanks.

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

  • Nice easy one today.

    Tom

  • This was removed by the editor as SPAM

  • Very easy question,thank you for the point.

    “When I hear somebody sigh, ‘Life is hard,’ I am always tempted to ask, ‘Compared to what?’” - Sydney Harris

  • Nice Easy question thanks

  • I can't believe that 21% have currently got it completely wrong, thinking that OR has precedence over AND! Hopefully they're just all misunderstanding what 'precedence' means 😉

  • Basic computer science question, nice and easy, thanks.

    Can't believe almost a third got it wrong!

    Bak to skool! 😛

    _____________________________________________________________________
    [font="Comic Sans MS"]"The difficult tasks we do immediately, the impossible takes a little longer"[/font]

  • nice question!!!

    back to basic!!!!

    Thanks!!


    [font="Times New Roman"]rfr.ferrari[/font]
    DBA - SQL Server 2008
    MCITP | MCTS

    remember is live or suffer twice!
    the period you fastest growing is the most difficult period of your life!
  • Toreador (5/24/2012)


    I can't believe that 21% have currently got it completely wrong, thinking that OR has precedence over AND! Hopefully they're just all misunderstanding what 'precedence' means 😉

    It seems more likely that they've misunderstood what MicroSoft means by "higher" on the BoL Page Operator Precedence. The question is sensibly phrased, using "has precedence over". The BoL page says "An operator on higher levels is evaluated before an operator on a lower level", and then provides a table with AND on level 6 and OR on level 7. It would not be unreasonable for people to think that level 7 is a higher level than level 6, and perhaps that accounts for the 21% very wrong answers. But level 7 is lower than level 6, as anyone who looks at the page layout (the right way up) can tell :w00t:.

    On that BoL page, a "higher" level is the one introduced closer to the top of the page, not one with a higher level number. Since the table is printed starting with level 1 at the top and continues in nummerical order of level number, the "higher level" is always the level with the lower number.

    The various BoL pages on this topic from SQL 2000 onwards have all misused "higher" in this sense; it was pointed out to MS about 12 years ago, but they think it's OK :crazy:. Perhaps they speak a different English in Redmond. 😉

    Edit: it is of course to be hoped that none of the people thinking OR has precedence over AND has ever written any T-SQL that depends on that misunderstanding - or if they have, that they wrote it so recently that they haven't yet done any unit testing!

    Tom

  • DugyC (5/24/2012)


    Basic computer science question, nice and easy, thanks.

    Can't believe almost a third got it wrong!

    Bak to skool! 😛

    "computer science" question? Since when was T-SQL operator precedence part of computer science? Do you think that all computer languages give AND precedence over OR? If so you will be surprised when you come across languages that give OR precedence over AND, languages that have left to right precedence, languages that have right to left precedence, and languages where not fixing evaluation order by overt syntactic means (using brackets or dots) is a syntax error.

    It is indeed surprising that so many got it wrong, though. I suspect it's MS's fault (see earlier post).

    Tom

  • L' Eomot Inversé, you make a fair point. BOL could do with some improving in this respect.

    Thank you all for you comments - much appreciated!

    :exclamation: "Be brave. Take risks. Nothing can substitute experience." :exclamation:

  • The only reason I had to think about it a while is that I would never combine AND and OR without parentheses, so that fact was a bit dusty in my brain. Yeah, it's something you should know, but it should also be something you don't have to worry about.

    ron

    -----
    a haiku...

    NULL is not zero
    NULL is not an empty string
    NULL is the unknown

  • A good question

    But,

    "Which of the following facts are correct when constructing a WHERE clause with no parenthesis?" ?

    Not all the statements are facts, only one is - "AND has precedence over OR".

    Thanks

    IgorMi

    Igor Micev,My blog: www.igormicev.com

  • This is something I pretty much never bother to remember, because if there's any ambiguity I always add parentheses...makes it easier for humans to understand that way.

Viewing 15 posts - 1 through 15 (of 40 total)

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