分析函数 AKA 窗口函数

Analytic functions (also known as window functions) are a special category of built-in functions. Like aggregate functions, they examine the contents of multiple input rows to compute each output value. However, rather than being limited to one result value per GROUP BY group, they operate on windows where the input rows are ordered and grouped using flexible conditions expressed through an OVER() clause.


窗口函数一般使用上都是配合over子句,对分组(窗口)进行操作,与group by聚合不同,窗口函数并不改变行数

比如聚合函数配合over子句中order by可以实现累加操作
sum(成绩) over (order by 学号) as cum_sum


留言

熱門文章