Michael J. Swart looks at how SQL Server implements order of operations:
I have a book on my shelf called Practical C Programming published by O’Reilly (the cow book) by Steve Oualline. I still love it today because although I don’t code in C any longer, the book remains a great example of good technical writing.
That book has some relevance to SQL today. Instead of memorizing the full list of operators and their precedence, Steve gives a practical subset:
- * (Multiply), / (Division)
- + (Add), – (Subtract)
Put parentheses around everything else.
Parentheses, even when unnecessary, are usually a good idea. They help the reader understand what was going through your mind at the time.
Comments closed