Oracle Arithmetic Operators

In Mathematics, basic operators (+, -, /, *) helps to add, subtract, divide or multiply two numbers. In oracle, they are arithmetic operators that perform an arithmetic operation between 2 numbers.

List of Arithmetic Operators

  1. + Operator: Used to add 2 numbers
  2. - Operator: Used to subtract numbers
  3. * Operator: Used to multiply numbers.
  4. / Operator: Used to divide numbers.
  5. MOD Operator: It is a special kind of Operator. For further reference, click here.

1. Arithmetic Operations on Numeric Values

Syntax

If it is between 2 numbers:

n1 Operator n2

where n1 and n2 are different numbers. 

Suppose we add a column Marks in a Stu table. we have the table stu shown below:

Stu
NameSectionRoll_NoSubjectMarks_Outof_100
RadhaB180Science56
ShrutiB16Science40
SnehaB17Science20
AkshitaC1Commerce80
BhoomikaC16Humanities78

To insert Values into the Table, click here

Example 1:  Now, we want to know marks of Students by adding 10 Marks more to the existing marks:

SELECT Name, Marks+10 FROM Stu;

Example 2: Same as above, we can use other mentioned operators ie. -,*,/ & %:

SELECT Name, Marks-10, Marks/10,Marks*10 FROM Stu;

Output:

Operators

Example 3: We want to first multiply the marks by 100 and divide the result by 10.

SELECT Name, (Marks*100)/10 FROM Stu;

Output

op

2. Arithmetic Operations on Date Values

We can only perform + & - Operator when it comes to Date. No * and / take place while working with Dates.

For example, we created another Variable ADD_Date that represents the Admission Date of a student in the Stu table.

Refer to the table given below:-

Date

Example 1: we want to perform + & - Operator with Add_Date:

SELECT ADD_Date+5 from Stu;

Output:

Date + operator

Example 2:

SELECT ADD_Date-5 from Stu;

Date - operator

NOTE:

  1. We cannot perform arithmetic operations with strings.
  2. Any calculation performed on NULL values will return NULL.