16 September 2013

SQL Arithmetic Operators



Assume variable a holds 20 and variable b holds 10 then


Operator
Description
Example
+
Addition - Adds values on either side of the operator
a + b will give 30
-
Subtraction - Subtracts right hand operand from left hand operand
a - b will give 10
*
Multiplication - Multiplies values on either side of the operator
a * b will give 200
/
Division - Divides left hand operand by right hand operand
a/ b will give 2
%
Modulus - Divides left hand operand by right hand operand and returns remainder
a % b will give 0

example:

--Addition

select 20+10

--Subtraction

select 20-10

--Multiplication

select 20*10

--Division

select 20/10

--Modulus

select 20%10

No comments:

Post a Comment