SQL Server Window Functions
This page lists the commonly used window functions in SQL Server.
-
DENSE_RANK
In SQL Server, theDENSE_RANK()
function is a ranking function that assigns a rank value to each row in a query result set. -
FIRST_VALUE
TheFIRST_VALUE()
function is a window function that returns the first value from a window. -
LAG
The SQL ServerLAG()
function is a window function that can be used to access the previous row of data in a query result set. -
LAST_VALUE
TheLAST_VALUE()
function is a window function in SQL Server used to retrieve the last value in a group. -
LEAD
TheLEAD()
function is a window function in SQL Server that retrieves data from the row after the current row. -
NTILE
In SQL Server, theNTILE()
function can divide a result set into a specified number of buckets and assign each row to one of the buckets. -
PERCENTILE_CONT
In SQL Server, thePERCENTILE_CONT()
function is a statistical function used to calculate the value corresponding to a specified percentile. -
PERCENTILE_DISC
PERCENTILE_DISC()
is an aggregate function in SQL Server used to calculate the specified percentile of a set of values. -
RANK
In SQL, theRANK()
function is used to assign ranks to rows in a result set based on specified sort criteria in ascending or descending order. -
ROW_NUMBER
ROW_NUMBER()
is a window function used to assign a unique row number to each row in a result set.