Syntax of / ( Divide ) Operators :
dividend / divisor
Dividend is the numeric expression to divide. Dividend can be any expression of numeric data type except datetime data type in sql server.
Divisor is the numeric expression to divide the dividend. Divisor can be expression of numeric data type except datetime in sql server.
Example of / ( Divide ) Operator :
Example 1 : Displays use of division for numeric numbers.
SELECT 4/2
Output
2
Above example explains how can we use divide operator for numeric numbers.
Example 2 : Example of diving digit from table field UnitPrice.
SELECT ProductName, UnitPrice / 3 AS Price
FROM Products
Output
ProductName Price
Chai 6.00
Chang 6.33
Aniseed Syrup 3.33
Chef Anton's Cajun Seasoning 7.33
Chef Anton's Gumbo Mix 7.12
Above example displays how can we use division operator with table field UnitPrice and numeric number 3.
Example 3 : Example of dividing 2 fields of tables.
SELECT ProductName, TotalCostOfEachProduct / UnitPrice AS UnitInStock
FROM Products
Output
ProductName UnitInStock
Chai 39
Chang 17
Aniseed Syrup 13
Chef Anton's Cajun Seasoning 53
Chef Anton's Gumbo Mix 0
Above example displays UnitInStock by dividing UnitPrice from TotalCostOfEachProduct of Products table.