Is order important?

  • mhtanner

    Mr or Mrs. 500

    Points: 530

    Comments posted to this topic are about the item Is order important?

  • This was removed by the editor as SPAM

  • funbi

    SSCarpal Tunnel

    Points: 4992

    I know it's not really the point of your question but

    select count(*) from x where n % 6 = 0 and not n % 5=0

    😀

  • DamianC

    SSCertifiable

    Points: 7767

    Interesting question and just so happened to have read about this last week!

    That's why I always use parenthesis

    They also make queries easier to read

    Especially with +, -, *, /, ... equations

    - Damian

  • Revenant

    SSC-Forever

    Points: 42468

    Thanks, Mike!

    BTW, why there are snippets a and c when they are not mentioned in possible replies? Just curious.

  • Lokesh Vij

    SSChampion

    Points: 10836

    Thanks Mike! A great way to reinforce the concepts 🙂

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

  • MMartin1

    One Orange Chip

    Points: 27488

    I figured B, though I was struggling with D and was glad that the options were this or not this rather than figuring out the math on D 🙂

    ----------------------------------------------------
    How to post forum questions to get the best help [/url]

  • Gary Varga

    SSC Guru

    Points: 82166

    DamianC (11/4/2016)


    Interesting question and just so happened to have read about this last week!

    That's why I always use parenthesis

    They also make queries easier to read

    Especially with +, -, *, /, ... equations

    I was taught to use parenthesis not only for the compiler but also for the maintainer. Consistently not using parenthesis and relying on precedence leaves an ambiguity whereas someone who consistently uses them is also clear in their intent if they omit them.

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!

  • Koen Verbeeck

    SSC Guru

    Points: 258890

    So much reading 😀

    Excellent question, thanks.

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

  • TomThomson

    SSC Guru

    Points: 104755

    Good question and explanation.

    In my experience many developers and dbas are unaware of operator precedence for other than arithmetic or boolean operations - perhaps because they pay only lip service to set-oriented thinking. So it's nice to see a queston on precedence for set-oriented operators.

    Tom

  • akljfhnlaflkj

    SSC Guru

    Points: 76202

    Good to know about the precedence, thanks.

Viewing 11 posts - 1 through 11 (of 11 total)

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