Let’s understand What is SQL Arithmetic Operators? In SQL, We can perform the Arithmetic operations on Table data. To perform the operations we need column names, numeric numbers, and arithmetic operators. Arithmetic operations can be performed only on those columns whose data type is Number or Date type.
SELECT <Expression>[arithmetic operator]<expression>… FROM [table_name] ;
Like – Select 20*20 from dual;
Arithmetic Operators in SELECT statement
There are 7 Arithmetic operators in SQL SELECT statement. We are listing all of these-
Addition (+) – We use plus(+) sign to perform addition on column values in SQL.
Substraction (-) – We use minus(-) sign to perform substraction on column values in SQL.
Multiply (*) – We use multiply(*) sign to perform Multiplication on column values in SQL.
Devide (/) – We use Devide(/) sign to perform devision on column values in SQL.
Modulo(%) – We use percentile(%) sign to calculate the mod values of the columns data.
In SQL order of operation follow the general rule of BODMAS rule. We can use Parentheses to force an operation to take priority over any other operators.
Arithmetic Operation using SQL Query
We are writing an SQL query to perform the simple arithmetic operation on Data.
SQL > SELECT First_name, Salary, Salary+300 form Employees;
In the result-set you can see, we are getting the values after addition operations.
Like about example, we can perform the multiplication as well. Let’s see the example below –
Products from Amazon.in
Price: Out of stock
Price: INR 29,999.00
Price: INR 14,999.00
SQL> Select Last_name, Salary, salary*Commission_Pct from Employees;
So using this we can perform the Arithmetic operations on the Data Table columns.