RAVG (window)
Syntax
RAVG( value [ , direction ] [ TOTAL | WITHIN ... | AMONG ... ] [ ORDER BY ... ] [ BEFORE FILTER BY ... ] )
Description
Returns the average of all values in a growing (or shrinking) window defined by the sort order and the value of direction
:
direction |
Window |
---|---|
"asc" |
Starts from the first row and ends at the current row. |
"desc" |
Starts from the current row and ends at the last row. |
By default "asc"
is used.
Window functions with a similar behavior: RSUM, RCOUNT, RMIN, RMAX.
Argument types:
value
—Number
direction
—String
Return type: Number (whole)
Note
Only constant values are accepted for arguments (direction
).
Warning
The sorting order is based on the fields listed in the chart's sorting section and in the function's ORDER BY
clause. First, ORDER BY
fields are used, and then they are complemented by the fields from the chart.
Examples
RAVG([Profit])
RAVG([Profit], "asc")
RAVG([Profit] TOTAL)
RAVG([Profit], "desc" WITHIN [Date])
RAVG([Profit] AMONG [Date])
Data source support
Materialized Dataset
, ClickHouse 1.1
, Microsoft SQL Server 2017 (14.0)
, MySQL 5.6
, Oracle Database 12c (12.1)
, PostgreSQL 9.3
.