The order of operations in SQL Server follows PEMDAS, so 6/2*(1+2) returns 9. This post walks through the precedence rules with tested queries. It also covers integer division, the negative number trap and AND before OR.
DATEDIFF Counts Boundaries, Not Time: Getting Durations Right
A report can say one year of service after a single day. Here is why DATEDIFF does that, and what to use instead.
Comparing Float Values: Why 0.1 + 0.2 Is Not 0.3 in SQL Server
Why does 0.1 + 0.2 miss 0.3 only when float is involved? A few tiny queries show the hidden digits, the drifting sum and two clean fixes.
Weighted Scores: Ranking Products by Several Columns at Once
Adding rating to units sold ranks by whichever column is biggest. Scale first, weigh second, and keep the weights in a table anyone can read.





