| title | Analytic Functions (Transact-SQL) | |
|---|---|---|
| description | Analytic Functions (Transact-SQL) | |
| author | markingmyname | |
| ms.author | maghan | |
| ms.reviewer | randolphwest | |
| ms.date | 05/09/2022 | |
| ms.service | sql | |
| ms.subservice | t-sql | |
| ms.topic | reference | |
| ms.custom |
|
|
| dev_langs |
|
|
| monikerRange | >=aps-pdw-2016 || =azuresqldb-current || =azure-sqldw-latest || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric || =fabric-sqldb |
[!INCLUDE sql-asdb-asdbmi-asa-pdw-edge-fabricse-fabricdw-fabricsqldb]
SQL Server supports these analytic functions:
- CUME_DIST (Transact-SQL)
- FIRST_VALUE (Transact-SQL)
- LAG (Transact-SQL)
- LAST_VALUE (Transact-SQL)
- LEAD (Transact-SQL)
- PERCENT_RANK (Transact-SQL)
- PERCENTILE_CONT (Transact-SQL)
- PERCENTILE_DISC (Transact-SQL)
Analytic functions calculate an aggregate value based on a group of rows. Unlike aggregate functions, however, analytic functions can return multiple rows for each group. Use analytic functions to compute moving averages, running totals, percentages or top-N results within a group.