Arithmetic calculation

The arithmetic expressions can be performed in SQL statements, which consist addition, subtraction, multiplication, and division. Arithmetic expressions can be done on numbers or dates. The four arithmetic operators are shown in the following table:

OperatorDescription
+Addition
-Subtraction
*Multiplication
/Division

SQL> SELECT 2 * 6 FROM dual;

       2*6
----------
        12

SQL>

multiplication and division are performed first, followed by addition and subtraction. If operators of the same precedence are used, they are performed from left to right.


SQL> SELECT 10 * 12 / 3 - 5 FROM dual;

 10*12/3-5
----------
        35

SQL>

You can use parentheses () to specify the order of execution for the operators:


SQL> SELECT 10 * (12 / 3 - 5)
  2  FROM dual;

10*(12/3-5)
-----------
        -10

SQL>

Arithmetic Operators in Order of Precedence

NameOperatorPrecedence
Parentheses( )1
Multiplication, Division*, /2
Addition, Subtraction+, -3
Home »
Oracle »
Select » 

Simple Select:
  1. Simple select statement
  2. Retrieve date type information from a table
  3. Retrieving All Columns from a Table
  4. ROWID:Row Identifiers
  5. ROWNUM:Row Numbers
  6. Arithmetic calculation
  7. Date Arithmetic
  8. Column Arithmetic
  9. Column Aliases
  10. Combining Column Using Concatenation
  11. distinct rows
Related: