Logo 
Search:

SQL Server Articles

Submit Article
Home » Articles » SQL Server » Operator RSS Feeds

Examples of / ( Divide ) Operator

Posted By: Sarita Patel     Category: SQL Server     Views: 9984

This article explains /( Divide ) operator with different examples.

Divide operator is used to perform division of any numeric type fields except datetime in sql server.

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. 


  
Share: 


Didn't find what you were looking for? Find more on Examples of / ( Divide ) Operator Or get search suggestion and latest updates.

Sarita Patel
Sarita Patel author of Examples of / ( Divide ) Operator is from United States.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!