Arithmetic Operators operate on one or more numeric operands and returns a numeric output.
Following are the arithmetic operators.
Table: Product
ProductID |
ProductName |
Price |
1 |
HD TV |
1000 |
2 |
Play Station |
400 |
3 |
MacBook |
2000 |
4 |
IMAC |
1500 |
5 |
IPOD |
200 |
6 |
XBOX |
500 |
7 |
MODEM |
100 |
8 |
Nintendo |
200 |
9 |
Speakers |
100 |
10 |
Printer |
200 |
11 |
SLR Camera |
1000 |
12 |
Tablet |
600 |
Example
Query :
SELECT ProductID, ProductName, Price,
Price + 10 AS 'Addition',
Price - 10 AS 'Subtraction',
Price * 10 AS 'Multiplication',
Price / 15 AS 'Division',
Price % 7 AS 'Modulo'
FROM Product
Output :
Description :
Here Addition, Subtraction and Multiplication columns are self-explanatory. Division column returns back the quotient when the Price (dividend) is divided by 15 (divisor).
It truncates the fractional part of the quotient. Modulo column returns back the reminder when the Price (dividend) is divided by 7 (divisor).