Saturday 20 July 2024

Window Frame in window function

 A window frame represents a specific subset of rows within a partition over which function applied. I means it is a collection of rows that have a connection to the current row which where the windows function is utilized for computation. It is vary for each function. A window frame can be defined using the partition by sub clause or row or range sub clause with in the over () clause of a window function.

The “Partition by “sub clause is like a virtual boundary of the dataset into smaller group or partition. Window function keep the original details. The partition in window function is just for calculations.

A window frame is a set of row related to take row in a dataset. The bounds of window frame define the range of rows over which a window function operates allowing customization of both lower and upper bounds. The “rows between “or “range between” clauses of a window function to specify these bounds.

  

Unbounded preceding: The start of the partition or window frame encompassing all rows from the beginning of the partition up to the current row.
N Preceding: N rows before the current row. It include that number of preceding rows. If N is zero it include only the current row.
Current Row: represent the current row being proceeding.
M following: n rows after the current row. It n is zero it includes only current row.
Unbounded following: End of the partition or frame. It including the all row from the current row to the end of the partition.

  Syntax

Range as below


No comments:

Post a Comment

If you have any doubt, please let me know.

Popular Posts