Monday, March 2, 2015

SQL: Mathematical Operators + , - , * , /


As you may have guessed the SQL mathematical operators are equivalent to their regular mathematical counter parts.

  1.  + Addtion
  2. - Subtraction
  3.  * Multiplication
  4.  / Division
Eamples:

1. Addition

SELECT UnitPrice, (UnitPrice + 20) AS RipOffPrice
FROM Products

2. Subraction

SELECT UnitPrice,(UnitPrice - 5) AS OutOfBusinessPrice
FROM Products
WHERE UnitPrice BETWEEN 5 AND 10


3. Muliplication

SELECT UnitPrice,(UnitPrice*UnitsInStock) AS InventoryPrice
FROM Products

4. Division

SELECT UnitPrice,(UnitPrice/2) AS HalfPrice
FROM Products


No comments:

Post a Comment