Skip to content

Latest commit

 

History

History
101 lines (74 loc) · 4.26 KB

divide-transact-sql.md

File metadata and controls

101 lines (74 loc) · 4.26 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs monikerRange
(Division) (Transact-SQL)
/ (Division) (Transact-SQL)
rwestMSFT
randolphwest
03/15/2017
sql
t-sql
reference
/
/_TSQL
/ (divide)
division [SQL Server]
divide operator (/)
TSQL
>= aps-pdw-2016 || = azuresqldb-current || = azure-sqldw-latest || >= sql-server-2016 || >= sql-server-linux-2017 || = azuresqldb-mi-current||=fabric

/ (Division) (Transact-SQL)

[!INCLUDE sql-asdb-asdbmi-asa-pdw-fabricse-fabricdw]

Divides one number by another (an arithmetic division operator).

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

Syntax

dividend / divisor  

[!INCLUDEsql-server-tsql-previous-offline-documentation]

Arguments

dividend
Is the numeric expression to divide. dividend can be any valid expression of any one of the data types of the numeric data type category, except the datetime and smalldatetime data types.

divisor
Is the numeric expression by which to divide the dividend. divisor can be any valid expression of any one of the data types of the numeric data type category, except the datetime and smalldatetime data types.

Result Types

Returns the data type of the argument with the higher precedence. For more information, see Data Type Precedence (Transact-SQL).

If an integer dividend is divided by an integer divisor, the result is an integer that has any fractional part of the result truncated.

Remarks

The actual value returned by the / operator is the quotient of the first expression divided by the second expression.

Examples

The following example uses the division arithmetic operator to calculate the sales target per month for the sales people at [!INCLUDEssSampleDBCoFull].

-- Uses AdventureWorks  
  
SELECT s.BusinessEntityID AS SalesPersonID, FirstName, LastName, SalesQuota, SalesQuota/12 AS 'Sales Target Per Month'  
FROM Sales.SalesPerson AS s   
JOIN HumanResources.Employee AS e   
    ON s.BusinessEntityID = e.BusinessEntityID  
JOIN Person.Person AS p   
    ON e.BusinessEntityID = p.BusinessEntityID;  

Here is a partial result set.

  
SalesPersonID FirstName    LastName          SalesQuota  Sales Target Per Month  
------------- ------------ ----------------- ----------- ------------------  
274           Stephen      Jiang             NULL        NULL  
275           Michael      Blythe            300000.00   25000.00  
276           Linda        Mitchell          250000.00   20833.3333  
277           Jillian      Carson            250000.00   20833.3333  
  

Examples: [!INCLUDEssazuresynapse-md] and [!INCLUDEssPDW]

The following example uses the division arithmetic operator to calculate a simple ratio of each employees' vacation hours to sick hours.

-- Uses AdventureWorks  
  
SELECT FirstName, LastName, VacationHours/SickLeaveHours AS PersonalTimeRatio  
FROM DimEmployee;  
  

See Also

Data Types (Transact-SQL)
Built-in Functions (Transact-SQL)
Operators (Transact-SQL)
SELECT (Transact-SQL)
WHERE (Transact-SQL)
/= (Division Assignment) (Transact-SQL)
Compound Operators (Transact-SQL)