As you may have guessed the SQL mathematical operators are equivalent to their regular mathematical counter parts.
- + Addtion
- - Subtraction
- * Multiplication
- / Division
Eamples:
2. Subraction
SELECT UnitPrice, (UnitPrice + 20) AS RipOffPrice
FROM Products
3. Muliplication
SELECT UnitPrice,(UnitPrice - 5) AS OutOfBusinessPrice
FROM Products
WHERE UnitPrice BETWEEN 5 AND 10
4. Division
SELECT UnitPrice,(UnitPrice*UnitsInStock) AS InventoryPrice
FROM Products
SELECT UnitPrice,(UnitPrice/2) AS HalfPrice
FROM Products
No comments:
Post a Comment