--- title: "CUME_DIST (Transact-SQL) | Microsoft Docs" ms.custom: "" ms.date: "07/24/2017" ms.prod: "sql-non-specified" ms.reviewer: "" ms.suite: "" ms.technology: - "database-engine" ms.tgt_pltfrm: "" ms.topic: "language-reference" f1_keywords: - "CUME_DIST" - "CUME_DIST_TSQL" dev_langs: - "TSQL" helpviewer_keywords: - "CUME_DIST function" - "analytic functions, CUME_DIST" ms.assetid: 491b07f3-9ffd-4cdd-93e5-5abb636fc5ef caps.latest.revision: 19 author: "BYHAM" ms.author: "rickbyh" manager: "jhubbard" --- # CUME_DIST (Transact-SQL) [!INCLUDE[tsql-appliesto-ss2012-asdb-asdw-xxx_md](../../includes/tsql-appliesto-ss2012-asdb-asdw-xxx-md.md)] Calculates the cumulative distribution of a value in a group of values in [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]. That is, CUME_DIST computes the relative position of a specified value in a group of values. For a row *r*, assuming ascending ordering, the CUME_DIST of *r* is the number of rows with values lower than or equal to the value of *r*, divided by the number of rows evaluated in the partition or query result set. CUME_DIST is similar to the PERCENT_RANK function. ![Topic link icon](../../database-engine/configure-windows/media/topic-link.gif "Topic link icon") [Transact-SQL Syntax Conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md) ## Syntax ```sql CUME_DIST( ) OVER ( [ partition_by_clause ] order_by_clause ) ``` ## Arguments OVER **(** [ *partition_by_clause* ] *order_by_clause***)** *partition_by_clause* divides the result set produced by the FROM clause into partitions to which the function is applied. If not specified, the function treats all rows of the query result set as a single group. *order_by_clause* determines the logical order in which the operation is performed. *order_by_clause* is required. The \ of the OVER syntax cannot be specified in a CUME_DIST function. For more information, see [OVER Clause (Transact-SQL)](../../t-sql/queries/select-over-clause-transact-sql.md). ## Return types **float(53)** ## Remarks The range of values returned by CUME_DIST is greater than 0 and less than or equal to 1. Tie values always evaluate to the same cumulative distribution value. NULL values are included by default and are treated as the lowest possible values. CUME_DIST is nondeterministic. For more information, see [Deterministic and Nondeterministic Functions](../../relational-databases/user-defined-functions/deterministic-and-nondeterministic-functions.md). ## Examples The following example uses the CUME_DIST function to compute the salary percentile for each employee within a given department. The value returned by the CUME_DIST function represents the percent of employees that have a salary less than or equal to the current employee in the same department. The PERCENT_RANK function computes the percent rank of the employee's salary within a department. The PARTITION BY clause is specified to partition the rows in the result set by department. The ORDER BY clause in the OVER clause logically orders the rows in each partition. The ORDER BY clause in the SELECT statement determines the display order of the result set. ```sql USE AdventureWorks2012; GO SELECT Department, LastName, Rate, CUME_DIST () OVER (PARTITION BY Department ORDER BY Rate) AS CumeDist, PERCENT_RANK() OVER (PARTITION BY Department ORDER BY Rate ) AS PctRank FROM HumanResources.vEmployeeDepartmentHistory AS edh INNER JOIN HumanResources.EmployeePayHistory AS e ON e.BusinessEntityID = edh.BusinessEntityID WHERE Department IN (N'Information Services',N'Document Control') ORDER BY Department, Rate DESC; ``` [!INCLUDE[ssResult](../../includes/ssresult-md.md)] ```sql Department LastName Rate CumeDist PctRank ---------------------- ---------------------- --------------------- ---------------------- ---------------------- Document Control Arifin 17.7885 1 1 Document Control Norred 16.8269 0.8 0.5 Document Control Kharatishvili 16.8269 0.8 0.5 Document Control Chai 10.25 0.4 0 Document Control Berge 10.25 0.4 0 Information Services Trenary 50.4808 1 1 Information Services Conroy 39.6635 0.9 0.888888888888889 Information Services Ajenstat 38.4615 0.8 0.666666666666667 Information Services Wilson 38.4615 0.8 0.666666666666667 Information Services Sharma 32.4519 0.6 0.444444444444444 Information Services Connelly 32.4519 0.6 0.444444444444444 Information Services Berg 27.4038 0.4 0 Information Services Meyyappan 27.4038 0.4 0 Information Services Bacon 27.4038 0.4 0 Information Services Bueno 27.4038 0.4 0 (15 row(s) affected) ``` ## See also [PERCENT_RANK (Transact-SQL)](../../t-sql/functions/percent-rank-transact-sql.md)