# SQL Arithmetic Operators

This page contains all the information, learn about SQL Arithmetic Operators concept in the SQL table with the help of examples.

The Arithmetic Operators is used to perform mathematical calculations on the numerical records or the value stored in the SQL table. The Arithmetic operator operates on two expressions like the addition of two values, subtraction of two values, multiplication of two values, division, and the modulus of two values. This operation is also performed on the columns of the SQL table.

The operator which comes under the arithmetic operator is as follows:

2 SQL Subtraction Operators (-)

3 SQL Multiplication Operators (*)

4 SQL Division Operators (/)

Consider the already existing table named Diploma_Student:

The SQL Addition operator is used to perform mathematical calculations on the numeric records of the given tables. You can use the addition operator to add the numeric values of the given columns from the mentioned table in the query by specifying column names as the operand.

The syntax of the SQL Addition operator is as follows:

`SELECT Column_Name1, Column_Name_2, Column_Name_3 + Column_Name_4 FROM Table_Name;`

Let’s understand how to execute addition operators in the SQL queries with the help of some examples.

Example 1: Execute a query to add First_Sem, Second_Sem, Third_Sem, Fourth_Sem, Fifth_Sem, and Sixth_Sem columns from the Diploma_Student.

`SELECT Student_Id, Student_Name, First_Sem + Second_Sem + Third_Sem + Fourth_Sem + Fifth_Sem + Sixth_Sem AS 'Addition of Percentage', Department_Id FROM Diploma_Student;`

In the above addition operator example, we have displayed the student id and student name and performed addition operations on First_Sem, Second_Sem, Third_Sem, Fourth_Sem, Fifth_Sem, and Sixth_Sem columns named column as ‘Addition of Percentage’. We have performed an addition operation on the multiple columns.

The output of the above query is as follows:

Example 2: Execute a query to perform an addition operation on the total field from the diploma_Student table.

`SELECT Student_Id, Student_Name, Total + 3 AS 'Add Percentage', Department_Id FROM Diploma_Student;`

In the above Addition operator query example, we added 3 percentages to each student to the Total Fields.

The output of the above query is as follows:

2 SQL Subtraction Operators (+):

The SQL Subtraction operator is used to perform mathematical calculations on the numeric records of the given tables. We can use the subtraction operator to subtract the numeric values of the given columns from the mentioned table in the query by specifying column names as the operand.

The syntax of the SQL Subtraction operator is:

`SELECT Column_Name1, Column_Name_2, Column_Name_3 - Column_Name_4 FROM Table_Name;`

Let’s understand how to execute subtraction operators in SQL queries with the help of some examples.

Example: Execute a query to subtract Sixth sem values from the Fifth sem values.

`SELECT Student_Id, Student_Name,  Fifth_Sem - Sixth_Sem AS 'Subtraction of values', Department_Id FROM Diploma_Student;`

In the above subtraction operator query example, we subtract the sixth Sem values from the fifth Sem values.

The output of the above query is:

3 SQL Multiplication Operators (+):

The SQL Multiplication operator is used to perform mathematical calculations on the numeric records of the given tables. We can use the Multiplication operator to multiply the numeric values of the given columns from the mentioned table in the query by specifying column names as the operand.

The syntax of the SQL Multiplication operator is:

`SELECT Column_Name1, Column_Name_2 * Column_Name_3, Column_Name_4 FROM Table_Name;`

Let’s understand how to execute Multiplication operators in the SQL queries with the help of some examples.

Example: Execute a query to multiply the first sem column by 2.

`SELECT Student_Id, Student_Name, First_Sem * 2 AS 'Multiplied by 2', Department_Id FROM Diploma_Student;`

In the above multiplication operator query example, we multiplied the first sem column value by 2.

The output of the above query is as follows:

4 SQL Division Operators (+):

The SQL Division operator is used to perform mathematical calculations on the numeric records of the given tables. We can use the Division operator to divide the numeric values of the given columns from the mentioned table in the query by specifying column names as the operand.

The syntax of the SQL Division operator is as follows:

`SELECT Column_Name1, Column_Name_2 / Column_Name_3, Column_Name_4 FROM Table_Name;`

Let’s understand how to execute Division operators in the SQL queries with the help of some examples.

Example: Execute a query to add First_Sem, Second_Sem, Third_Sem, Fourth_Sem, Fifth_Sem, and Sixth_Sem columns and divide the value by 6.

`SELECT Student_Id, Student_Name, (First_Sem + Second_Sem + Third_Sem + Fourth_Sem + Fifth_Sem + Sixth_Sem)/6 AS 'Division Operation', Department_Id FROM Diploma_Student;`

In the above Division operator query example, we first added values from the First_Sem, Second_Sem, Third_Sem, Fourth_Sem, Fifth_Sem, and Sixth_Sem and then divided the value by 6. We performed multiple operations in the above query.

The output of the above query is as follows: