As you may have guessed the SQL mathematical operators are equivalent to their regular mathematical counter parts.
- + Addtion
- - Subtraction
- * Multiplication
- / Division
Eamples:
SELECT UnitPrice, (UnitPrice + 20) AS RipOffPrice
FROM Products

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

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

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

No comments:
Post a Comment