×

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:

1 SQL Addition Operators (+)

2 SQL Subtraction Operators (-)

3 SQL Multiplication Operators (*)

4 SQL Division Operators (/)

Consider the already existing table named Diploma_Student:

Student_IdStudent_NameFirst_SemSecond_SemThird_SemFourth_SemFifth_SemSixth_SemTotalDepartment_Id
202111Vaishnavi Patil949188859592911
202112Vaibhav Lokhande859092808582862
202113Yash Dhull908894878590893
202114Sonali Patole959092889290914
202115Axar Patel858082869284851
202116Meena Mishra787580748577783
202117Mahesh Kumbhar758075788076775
202118Sakashi Patil807874788077782
202119Sopan Bhore706875758080752
202220Prajwal Lokhande808585757880814
202221Anuja Wanare858886828485855
202222Venkatesh Iyer908987909291903
202223Anushka Sen707571748078751
202224Aakash Jain807572748580784
202225Akshay Agarwal858078889082845

1 SQL Addition Operators (+)

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:

Student_IdStudent_NameAddition of PercentageDepartment_Id
202111Vaishnavi Patil5451
202112Vaibhav Lokhande5142
202113Yash Dhull5343
202114Sonali Patole5474
202115Axar Patel4091
202116Meena Mishra4693
202117Mahesh Kumbhar4645
202118Sakashi Patil4672
202119Sopan Bhore4482
202220Prajwal Lokhande4834
202221Anuja Wanare5105
202222Venkatesh Iyer5393
202223Anushka Sen4481
202224Aakash Jain4664
202225Akshay Agarwal5035
SQL Arithmetic Operators

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:

Student_IdStudent_NameAdd PercentageDepartment_Id
202111Vaishnavi Patil941
202112Vaibhav Lokhande892
202113Yash Dhull923
202114Sonali Patole944
202115Axar Patel881
202116Meena Mishra813
202117Mahesh Kumbhar805
202118Sakashi Patil812
202119Sopan Bhore782
202220Prajwal Lokhande844
202221Anuja Wanare885
202222Venkatesh Iyer933
202223Anushka Sen781
202224Aakash Jain814
202225Akshay Agarwal875
SQL Arithmetic Operators

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:

Student_IdStudent_NameSubtraction of valuesDepartment_Id
202111Vaishnavi Patil31
202112Vaibhav Lokhande32
202113Yash Dhull-53
202114Sonali Patole24
202115Axar Patel81
202116Meena Mishra83
202117Mahesh Kumbhar45
202118Sakashi Patil32
202119Sopan Bhore02
202220Prajwal Lokhande-24
202221Anuja Wanare-15
202222Venkatesh Iyer13
202223Anushka Sen21
202224Aakash Jain54
202225Akshay Agarwal85
SQL Arithmetic Operators

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:

Student_IdStudent_Name Multiplied by 2Department_Id
202111Vaishnavi Patil1881
202112Vaibhav Lokhande1702
202113Yash Dhull1803
202114Sonali Patole1904
202115Axar Patel1701
202116Meena Mishra1563
202117Mahesh Kumbhar1505
202118Sakashi Patil1602
202119Sopan Bhore1402
202220Prajwal Lokhande1604
202221Anuja Wanare1705
202222Venkatesh Iyer1803
202223Anushka Sen1401
202224Aakash Jain1604
202225Akshay Agarwal1705
SQL Arithmetic Operators

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:

Student_IdStudent_NameDivision OperationDepartment_Id
202111Vaishnavi Patil90.83331
202112Vaibhav Lokhande85.66672
202113Yash Dhull89.00003
202114Sonali Patole91.16674
202115Axar Patel84.83331
202116Meena Mishra78.16673
202117Mahesh Kumbhar77.33335
202118Sakashi Patil77.83332
202119Sopan Bhore74.66672
202220Prajwal Lokhande80.50004
202221Anuja Wanare85.00005
202222Venkatesh Iyer89.83333
202223Anushka Sen74.66671
202224Aakash Jain77.66674
202225Akshay Agarwal83.83335
SQL Arithmetic Operators

Related Topics

SQL DROP Database

This tutorial will help us understand how to drop a database from the SQL Server with a few examples. The DROP command removes all the objects stored in the database and...

4 minutes read.

SQL SELECT LIKE Operator

The SQL SELECT LIKE Operator tutorial helps us understand how to use the LIKE operator in the SELECT query with examples. The SQL SELECT LIKE Operator retrieves the records from the...

4 minutes read.

SQL Temporary Tables

Temporary Table: The Temporary tables are generally created in TempDB. If the last connection is terminated then the tables are deleted automatically. These are generally used to store and process the...

4 minutes read.

Difference between SQL and NoSQL

SQL vs. NoSQL | Difference between SQL and NoSQL Choosing a database is the most fundamental decision that needs to be decided before starting a task. Relational and non-relational databases are...

3 minutes read.

How to use the BETWEEN operator in SQL

In this entire SQL article, we will understand and learn about the BETWEEN operator concept and how to use it in SQL. What is the BETWEEN operator in SQL? The Between operator...

4 minutes read.

SQL DELETE

In this tutorial, you will learn about the SQL DELETE concept by using examples. In Structured Query Language (SQL), we fetch the data from the database table using SELECT Statement and...

3 minutes read.

SQL SET Keyword

This article will provide you a good understanding of the Set keyword in Structured Query Language. What is the SET keyword? The SET keyword is used to specify values for the variables....

3 minutes read.

SQL Syntax

In this tutorial, we will help you understand about the different SQL Syntax concepts with the help of an example. Every Structured Query Language starts with Keywords like select, insert, update,...

5 minutes read.

WHERE Clause vs HAVING Clause

The WHERE Clause and HAVING clause filter the records in the Structured Query Language queries. The main difference between the WHERE clause and the HAVING clause is the WHERE clause...

5 minutes read.

SQL Data Control Language

Data Control Language decides to whom should (which user) permit access privileges. GRANT and REVOKE are the commands of DCL. GRANT: It gives privileges to user. REVOKE: It takes back privileges from granted...

1 minute read.

SQL Aggregate Operators

In SQL, the aggregate operators perform a calculation on multiple rows or multiple values of a single column and give the output a single value. Here, multiple rows of data are...

4 minutes read.

SQL Wildcards

SQL WILDCARD CHARACTERS: SQL wild card character is used to substitute zero or more characters of a string. These characters are used with the “LIKE” operator. Wild Card Characters in SQL: %_[]^- “%” : It is...

3 minutes read.

Commit and Rollback in SQL

In Structured Query Language, we have Data Definition Language (DDL) and Data Manipulation Language (DML) commands the same way we have Transaction Control Language (TCL) commands in the Structured Query...

4 minutes read.

SQL WHERE Statement

SQL WHERE Statement Introduction WHERE clause is used to include a condition while fetching data from tables.When you have to specify a condition that has to be obeyed while data is...

9 minutes read.

Drop vs Truncate in SQL

In this article, we will learn and understand the Drop and Truncate commands and the difference between these two commands. What is Drop Command? Drop is a Data Definition Language command in...

6 minutes read.

How to use HAVING clause in SQL

In this article, we will learn about the HAVING clause concept and how to use it in SQL. What is the HAVING clause? In Structured Query Language, HAVING Clause used with GROUP...

7 minutes read.

SQL Topological Sorting

It is for Directed Acyclic Graph, which linearly describes the ordering of graphs. It is not possible for all graphs, it is possible for only Directed acyclic graphs. Applications of Topological...

3 minutes read.

SQL Aliases

SQL Aliases: These are used to give a temporary name for a column or table. These are used to make tables or columns more readable. These are used to rename the table...

2 minutes read.

SQL Cloning Tables

Cloning a Table: To create a copy of the table. To perform the operations, without affecting the actual table. Steps for creating a Cloning Table: Step 1: Empty Table Creation The syntax for Creating...

3 minutes read.

How to remove duplicates in SQL

Introduction There are some specific rules that needs to be followed while creating the database objects. To improve the performance of a database, a primary key, clustered and non-clustered indexes, and...

9 minutes read.