Tuesday, 13 January 2015

How To Override Arithmetic Operator Precedence Rule In SQL

Parentheses are used to override the precedence rule. If you look at the previous example, the expression was executed in this order (for King): 12 * 24000 + 1000. In the current scenario, the result has changed because of the inclusion of the parentheses. In this case the expression is evaluated like this: (24000 + 1000) * 12.


    SQL Statement 

SELECT       last_name, salary, 12 * (salary + 1000)
FROM          employees;

    Output :






















No comments:

Post a Comment