Search code examples
sqlsql-serveroperator-precedence

SQL Operator presedence


How

SELECT 80/9*9

results 72 in SQL Server.

I followed the below link but I am getting a different answer. RedGate


Solution

  • As Juergen says, they have the same precedence and with integer division it does:

    80/9 = 8 (as the remainder/decimal part is removed)
    

    If an integer dividend is divided by an integer divisor, the result is an integer that has any fractional part of the result truncated.

    Then:

    8 * 9 = 72