In SQL, Operators are special character, symbol or a keyword that is used to perform some specific operations. For example : comparing data
SQL operators are commonly used with SQL statements to retrieve, filter, and manipulate data.
SQL arithmetic operators can be used to perform mathematical calculation on numeric data types such as int, float and decimal.
• Addition + • Subtraction - • Multiplication * • Division / • Modulo %
SELECT 2 + 1 AS [Addition] SELECT 2 - 1 AS [Subtraction] SELECT 2 * 1 AS [Multiplication] SELECT 10 / 2 AS [Division] SELECT 10 % 3 AS [Modulo]
It is a operator denoted by plus (+) symbol and use to add two numerical values together.
For example : if you have two numerical values as 2 and 1. The addition of these two numbers will result 3.
2 + 1 = 3
It is a operator denoted by minus (-) symbol and use to subtract one numerical value from another numerical value. Basically it calculates the difference between two numbers.
For example : if you have two numerical values as 2 and 1. The subtraction of value 1 from value 2 will result 1.
2 - 1 = 1
It is a operator denoted by asterisk (*) symbol and use to multiply two numerical values together.
For example : if you have two numerical values as 2 and 1. The multiplication of these two numbers will result 2.
2 * 1 = 2
It is a operator denoted by forward slash (/) symbol and use to divide one numerical value by another numerical value.
For example : if you have two numerical values as 10 and 2. The division of these two numbers will result 5.
10 / 2 = 5
It is a operator denoted by percent (%) symbol and use to calculate remainder when one numerical value is divided by another numerical value.
For example : if you have two numerical values as 10 and 3. The remainder of these two numbers will result 1.
10 % 3 = 1
Arithmetic operators in SQL include addition (+), subtraction (-), multiplication (*), division (/), and modulus (%).
The five arithmetic operators in SQL are addition (+), subtraction (-), multiplication (*), division (/), and modulus (%).
In SQL, "=>" is not a valid operator; it is commonly used in other programming languages like PHP, but not in SQL.
The precedence of arithmetic operators in SQL follows the typical mathematical rules: multiplication and division have higher precedence than addition and subtraction.