## SQL Arithmetic OperatorsIn Structured Query Language, the arithmetic operators are used to perform mathematical operations on the numerical values stored in the database tables. We can use these operators with the SELECT statement in SQL. We can also use the WHERE clause in the SELECT statement for performing operations on particular rows. These types of operators are used between two numerical operands for performing addition, subtraction, multiplication, and division operations.
- SQL Addition Operator (+)
- SQL Subtraction Operator (-)
- SQL Multiplication Operator (*)
- SQL Division Operator (/)
- SQL Modulus Operator (%)
## SQL Addition Operator (+)The SQL Addition Operator performs the addition on the numerical columns in the table. If you want to add the values of two numerical columns in the table, then you have to specify both columns as the first and second operand. You can also add the new integer value in the value of the integer column.
## Addition Operator with WHERE ClauseThe addition operator can also be used with the WHERE clause in the SQL SELECT query.
The following CREATE query creates the Employee table with five fields: The following INSERT query inserts the record of employees into the Employee table: The following SELECT query shows the data of
The following query adds the Emp_Salary and Emp_Bonus of each employee of the
The following query adds 15000 to the salary of each employee in the Emp_Salary column of
The following query performs the addition operation on the above It shows only records of those employees whose Emp_Salary is greater than 25000:
## SQL Subtraction Operator (-)The SQL Subtraction Operator performs the subtraction on the numerical columns in the table. If we want to subtract the values of one numerical column from the values of another numerical column, then we have to specify both columns as the first and second operand. We can also subtract the integer value from the values of the integer column.
## Subtraction Operator with WHERE ClauseThe subtraction operator can also be used with the WHERE clause in the SELECT query.
The following CREATE query creates the Employee table with five fields: The following INSERT query inserts the record of employees into the Employee table: The following SELECT query shows the data of
The following query subtracts the values of the Emp_Panelty column from the Emp_Salary column of the
The following query performs the subtraction operation on the above It shows only records of those employees whose Employee_ID is 103:
The following query subtracts 10000 from the salary of each employee of the
## SQL Multiplication Operator (*)The SQL Multiplication Operator performs the multiplication on the numerical columns in the table. If you want to multiply the values of two numerical columns, then you have to specify both columns as the first and second operand. You can also multiply the integer value with the values of an integer column.
## Multiplication Operator with WHERE ClauseThe multiplication operator (*) can also be used with the WHERE clause in the SELECT query.
The following CREATE query creates the Cars table with four fields: The following INSERT query inserts the record of cars into the Cars table: The following SELECT query shows the data of
The following query multiplies the values of the
The following query performs the multiplication operation on the above Cars table with the WHERE clause: It shows only those records of cars whose
## SQL Division Operator (/)The SQL Division operator divides the numerical values of one column by the numerical values of another column.
## Division Operator with WHERE ClauseThe SQL division operator can also be used with the WHERE clause in the SELECT query.
The following CREATE query creates the The following INSERT query inserts the record of cars into the The following SELECT query shows the data of
The following query divides the values of the Car_Price column by the Car_Amount column of the
The following query performs the division operation on the above Cars table with the WHERE clause: It shows the record of those cars whose Car_Number is 9258 from the Cars table.
## SQL Modulus Operator (%)The SQL Modulus Operator provides the remainder when the numerical values of one column are divided by the numerical values of another column.
The following CREATE query creates the Student table with four fields: The following INSERT query inserts the record of the student into the Student table: The following SELECT query shows the data of
The following query divides the marks Student_English column by Marks of Student_Maths of each student in the Student table:
The following query performs the modulus operation on the above Student table with the WHERE clause: It shows the record of those students whose Student_Id is greater than 202.
Next TopicHow to Use GROUP BY in SQL |