Oracle Arithmetic Operators

You may not always want to retrieve the data as is. In some cases, you may want to display your data with certain calculation, or look at a what-if scenarios (for example, you may want to know how the prices would look like after adding VAT).

Arithmetic Operations on Numeric Values

The Oracle query in this example calculates the product’s price after an addition of 20%.

It is advisable to specify the original column without the change (unit_price) in addition to the column with the calculation (unit_price *1.2), in order to make the difference – in this example, the increase – visible.

Arithmetic Operations on NULL Values

In Oracle A NULL value is a value that indicates an empty field in a table. This value does not equal zero (0), nor does it equal space (‘ ‘); When a certain calculation is carried out on a column that contains NULL values, any calculation performed on the NULL value returns NULL.

The discount column is a column that contains NULL values. Each calculation on a field in this column that contains NULL value returns NULL.

General Guidelines

In Oracle calculations on columns (of any data type) do not modify the contents (actual data) of the column in the table, but only display the column’s contents for that specific query, in another way.

In Oracle Calculations on columns change the column’s header’s in the output (this issue will be addressed in the next post – Column Aliases)