From 90244946b8fb2fa41ffad6685bc23e23e553b7c6 Mon Sep 17 00:00:00 2001 From: Gabriel Donizeti Candido Date: Fri, 11 Sep 2026 09:39:48 -0300 Subject: [PATCH 1/2] Update SUM function syntax and OVER clause details Added row_or_range_clause to the SUM function syntax and updated the OVER clause description to include its default behavior. --- docs/t-sql/functions/sum-transact-sql.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/t-sql/functions/sum-transact-sql.md b/docs/t-sql/functions/sum-transact-sql.md index 3aa46bdf7f7..770df269913 100644 --- a/docs/t-sql/functions/sum-transact-sql.md +++ b/docs/t-sql/functions/sum-transact-sql.md @@ -41,7 +41,7 @@ Returns the sum of all the values, or only the `DISTINCT` values, in the express SUM ( [ ALL | DISTINCT ] expression ) -- Analytic Function Syntax -SUM ( [ ALL ] expression) OVER ( [ partition_by_clause ] [ order_by_clause ] ) +SUM ( [ ALL ] expression) OVER ( [ partition_by_clause ] [ order_by_clause ] [row_or_range_clause] ) ``` ## Arguments @@ -58,11 +58,15 @@ Specifies that `SUM` returns the sum of unique values. A constant, column, or function, and any combination of arithmetic, bitwise, and string operators. *expression* is an expression of the exact numeric or approximate numeric data type category, except for the **bit** data type. Aggregate functions and subqueries aren't permitted. For more information, see [Expressions](../language-elements/expressions-transact-sql.md). -#### OVER ( [ *partition_by_clause* ] [ *order_by_clause* ] ) +#### OVER ( [ *partition_by_clause* ] [ *order_by_clause* ] [ *row_or_range_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. For more information, see [SELECT - OVER clause](../queries/select-over-clause-transact-sql.md). +*order_by_clause* determines the logical order in which the operation is performed. If *row_or_range_clause* isn't specified, it assumes its default value. + +*row_or_range_clause* defines the window frame in which the function is applied. The default value is `RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW`. It requires *order_by_clause* to be specified. + +For more information, see [SELECT - OVER clause](../queries/select-over-clause-transact-sql.md). ## Return types From 6dd7423383c474e4dd8678d30e82912c69e409c2 Mon Sep 17 00:00:00 2001 From: Gabriel Donizeti Candido Date: Fri, 11 Sep 2026 14:41:47 -0300 Subject: [PATCH 2/2] Update OVER clause explanation in sum-transact-sql.md Clarified the requirements for order_by_clause and row_or_range_clause in the OVER clause section. --- docs/t-sql/functions/sum-transact-sql.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/t-sql/functions/sum-transact-sql.md b/docs/t-sql/functions/sum-transact-sql.md index 770df269913..16b067c5a47 100644 --- a/docs/t-sql/functions/sum-transact-sql.md +++ b/docs/t-sql/functions/sum-transact-sql.md @@ -62,9 +62,9 @@ A constant, column, or function, and any combination of arithmetic, bitwise, and *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. If *row_or_range_clause* isn't specified, it assumes its default value. +*order_by_clause* determines the logical order in which the operation is performed. -*row_or_range_clause* defines the window frame in which the function is applied. The default value is `RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW`. It requires *order_by_clause* to be specified. +*row_or_range_clause* defines the window frame in which the function is applied. It requires *order_by_clause* to be specified. If *order_by_clause* is specified and *row_or_range_clause* isn't, *row_or_range_clause* assumes its default value `RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW`. For more information, see [SELECT - OVER clause](../queries/select-over-clause-transact-sql.md).