Https://docs.microsoft.com/en-us/sql/t-sql/queries/select-over-clause-transact-sql
Determines the partitioning and ordering of a rowset before the associated window function is applied.
That's, the over clause defines a window or user-specified set of rows within a query result set.
A window function then computes a value for each row in the window.
You can use the over clause with functions to compute aggregated values such as moving averages, cumulative cumulative aggregates, Running totals, or a top N per group results.
Group
PARTITION by
Divides the query result set into partitions.
The window function is applied to each partition separately and computation restarts for each partition.
GROUP BY what
Alue_expression
Specifies the column by which the rowset is partitioned.
Value_expression can only refer to columns made available by the FROM clause.
Value_expression cannot refer to expressions or aliases in the select list.
value_expression can be a column expression, scalar subquery, scalar function, or user-defined variable.
<order by clause>
Defines the logical order of the rows within each partition of the result set.
That's, it specifies the logical order in which the Windows Functioncalculation is performed.
order_by_expression
Specifies a column or expression on which to sort.
Order_by_expression can only refer to columns made available by the FROM clause.
An integer cannot is specified to represent a column name or alias.
Actual combat
withTemp2 as(SELECTId,[ Number], Row_number () Over(ORDER by(SELECT 1)) asSNO fromdbo. Testpartition)SELECTTemp2. Id, Temp2. Number , SUM( Number) Over(PARTITION byTemp2. IdORDER byTemp2. SNO) as 'Number Cumulative value' fromTemp2
Window functions Select-over Clause (Transact-SQL)