The SQL Arithmetic Operators are used to perform Arithmetic operations such as Addition, Subtraction, Multiplication and Division on given Data. Following table shows the list of available Arithmetic operators in SQL Server.

SQL Arithmetic Operators |
Operation |
Example |
---|---|---|

+ |
Addition | DECLARE @A INT, @B INT SET @A = 10 SET @B = 2 SELECT @A + @B AS Total = 12 |

– |
Subtraction | SELECT @A – @B AS Total (10 – 2 = 8) |

* |
Multiplication | SELECT @A * @B AS Total (10 * 2 = 20) |

/ |
Division | SELECT @A / @B AS Total (10 / 2 = 5) |

% |
Modulus – It returns the remainder after the division | SELECT @A % @B AS Total =0 because 10%2 = 0 (Here remainder is zero). If it is 10 % 3 then it will be 1. |

In this article we will show you, How to use these Arithmetic Operators in SQL Server with examples. For this, We are going to use the below shown data

## SQL + Operator (Addition)

In SQL Server, Addition Operator is useful in multiple ways. If we use the addition operator on Numerical data then it will add those values and provide the integer output. If we used the Addition operator in between two strings then it will combine them and provide string output. For example, The following query will combine the [EnglishProductName] and [Color] columns

SELECT [EnglishProductName] + ' - ' + [Color] AS [Product Name] ,[StandardCost] ,[DealerPrice] ,[SalesAmount] ,[TaxAmt] FROM [Product Sales]

**NOTE:** ‘-‘ is added between the product name and color

**OUTPUT**

Let us see, How to perform Addition on Numerical Data. For example, We want to increase the standard cost of each product then we can use this addition operator to add the constant value.

SELECT [EnglishProductName] ,[Color] ,[StandardCost] + 2.25 AS [New Standard Cost] ,[DealerPrice] ,[SalesAmount] ,[TaxAmt] FROM [Product Sales]

Above SQL Query is adding 2.25 to the standard cost of every product present in the Product Sales table

**OUTPUT**

## SQL – Operator ( Subtraction )

The Subtract Operator is used to subtract one value from the other. For example, The following query will calculate the Profit Margin by subtracting the standard cost from the dealer price.

SELECT [EnglishProductName] ,[Color] ,[StandardCost] ,[DealerPrice] ,[DealerPrice] - [StandardCost] AS [Product Margin] ,[SalesAmount] ,[TaxAmt] FROM [Product Sales]

**OUTPUT**

## SQL * Operator (Multiplication)

The Multiplication Operator is used to Multiply one value with the other. For example, The following query will calculate the Tax for late payments.

SELECT [EnglishProductName] ,[Color] ,[StandardCost] ,[DealerPrice] ,[SalesAmount] ,[TaxAmt] * 2 AS [Double Taxation] FROM [Product Sales]

Here we are multiplying the original Tax amount with 2.

**OUTPUT**

## SQL / Operator (Division)

The Division Operator is used to Divide one value with the other. For example, The following query will calculate the percentage of Tax we are paying for each individual product.

SELECT [EnglishProductName] ,[Color] ,[StandardCost] ,[DealerPrice] ,[SalesAmount] ,[TaxAmt] ,[SalesAmount] / [TaxAmt] AS [Tax Percent] FROM [Product Sales]

**OUTPUT**

Thank You for Visiting Our Blog