Analytic Functions
Analytic Functions
windowing_clause
We have seen previously the query_partition_clause controls the window, or group of
rows, the analytic operates on. The windowing_clause gives some analytic functions a further
degree of control over this window within the current partition, or whole result set if no
partitioning clause is used. The windowing_clause is an extension of
the order_by_clause and as such, it can only be used if an order_by_clause is present.
The windowing_clause has two basic forms.
UNBOUNDED PRECEDING : The window starts at the first row of the partition, or the
whole result set if no partitioning clause is used. Only available for start points.
UNBOUNDED FOLLOWING : The window ends at the last row of the partition, or the whole
result set if no partitioning clause is used. Only available for end points.
CURRENT ROW : The window starts or ends at the current row. Can be used as start or
end point.
value_expr PRECEDING : A physical or logical offset before the current row using a
constant or expression that evaluates to a positive numerical value. When used
with RANGE, it can also be an interval literal if the order_by_clause uses
a DATE column.
value_expr FOLLOWING : As above, but an offset after the current row.
With expression
Count the number ordered created on same date for same customer.
Oracle LAG
in this tutorial, you will learn how to access the row at a given offset prior to the current row
using Oracle LAG() function.
Oracle LAG() is an analytic function that allows you to access the row at a given offset prior to
the current row without using a self-join.
In this syntax: