Tuesday 28 May 2013

Operator Precedence in SELECT statement


*      /     +     -

  • Multiplication and division take priority over addition and subtraction
  • Operators of the same priority are evaluated from left to right 
  • Parentheses are used to force prioritized evaluation and to clarify statements
Operator Precedence with example

SELECT ename,sal,12*sal+100 
FROM emp;

SELECT ename,sal,12*(sal+100)
FROM emp;


In the above examples parentheses makes a lot of differences in arithmetic calculation.



No comments:

Post a Comment