• A boat with beautiful sunset.
  • Tree in field with blue sky.
  • Amaizing sunrise moment

Friday, March 16, 2012

Operator Precedence




*
/
+
-

  • 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 clarify statements.
Example :

SELECT emp_name,salary, 12*salary+200 FROM dept;

Note :

It calculated the annual income as 12 multiplied by the monthly salary,plus a one-time bonus of 200.

USING PARENTHESES :

Example :

SELECT emp_name, salary,12*(salary+200) FROM dept;

Note :

It calculated the annual income as monthly salary plus a monthly bonus of 200,multiplied by 12.


No comments:

Post a Comment