In SQL, arithmetic operators are useful to perform mathematical operations like addition ( ), subtraction (-), multiplication (*), division (/), module (%) on SQL statements. In SQL, we have a different type of arithmetic operators available, those are
In SQL, addition operator are used to perform an addition of numbers .
Example:
Following is the example of using addition operator in sql server.
Select 17+5
If we execute the above SQL query, we will get the result as 22.
In SQL, the subtraction operator is useful to perform a subtraction of numbers.
Example:
Following is the example of using subtraction operator in sql server.
Select 17-5
If we execute above SQL query, we will get the result as 12.
In SQL, the multiple operator is useful to perform multiplication of numbers.
Example:
Following is the example of using a multiplication operator in sql server.
Select 17*5
If we execute above SQL query, we will get the result as 85.
In SQL, division operator is used to perform a division of numbers.
Example:
Following is the example of using a division operator in sql server.
Select 17/5
If we execute the above SQL query, we will get the result as 3.
In SQL, the modulus operator is useful to perform a division of numbers and returns a remainder of division operation.
Example:
Following is the example of using a modulus operator in sql server.
Select 17%3
If we execute above SQL query, we will get the result as 2.
For more information related to arithmetic operators, check the following information.
Operator | Description | Example |
---|---|---|
+ (Addition) | By using this operator we can perform the addition of numbers. | 17 + 5 = 22 |
- (Subtraction) | By using this operator we can perform subtraction of numbers. | 17 – 5 = 12 |
* (Multiplication) | By using this operator we can perform multiplication of numbers. | 17 * 5 = 85 |
/ (Division) | By using this operator we can perform division of numbers. | 17 / 5 = 3 |
% (Modulus) | This operator returns the remainder of a division operation. | 17 % 5 = 2 |