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


Comments

Popular posts from this blog

Installing AdventureWorks Sample Databases from Microsoft

SQL: GROUP BY And HAVING

ASP.NET : Create an Empty Web Application Project in Visual Studio 2012