Arithmetic
Expressions
Add : +
Subtract : -
Multiply : *
Divide : /
Arithmetic
Operators
You can use arithmetic operators in any
clause of a SQL statement (except the FROM clause).
Note: With the DATE and TIMESTAMP data types, you
can use the addition and subtraction
operators only.
Rules of
Precedence
• Multiplication and division occur before
addition and subtraction.
• Operators of the same priority are
evaluated from left to right.
• Parentheses are used to override the
default precedence or to clarify the statement.
Examples :
SELECT last_name, salary, salary + 300 FROM
employees;
SELECT last_name, salary, 12*(salary + 300) FROM
employees;
In the above example , salary of each
employee is added with 300 and finally multiplied by 12 to the annual salary of employee. Here parentheses () is used to override
default precedence.