平均值分析函数

AVG([DISTINCT|ALL] expr) OVER(analytic_clause)

用途:计算特定分析范围内的平均值。

举例:

- 聚合函数:SELECT col, AVG(value) FROM tmp1 GROUP BY col ORDER BY col;

- 分析函数:SELECT col, AVG(value) OVER(PARTITION BY col ORDER BY col) FROM tmp1 ORDER BY col;

求和分析函数

SUM ( [ DISTINCT | ALL ] expr ) OVER ( analytic_clause )

用途:计算特定分析范围内的求和。

举例:

- 聚合函数:SELECT col, sum(value) FROM tmp1 GROUP BY col ORDER BY col;

- 分析函数:SELECT col, sum(value) OVER(PARTITION BY col ORDER BY col) FROM tmp1 ORDER BY col;