SelectDB Cloud
SQL 手册
函数
window-functions
WINDOW-FUNCTION-MAX

WINDOW FUNCTION MAX

description

LEAD() 方法用来计算窗口内的最大值。

MAX([DISTINCT | ALL] expression) [OVER (analytic_clause)]

example

计算从第一行到当前行之后一行的最大值

select x, property,   
max(x) over    
(   
order by property, x    
rows between unbounded preceding and 1 following    
) as 'local maximum'    
from int_t where property in ('prime','square');
 
| x | property | local maximum |
|---|----------|---------------|
| 2 | prime    | 3             |
| 3 | prime    | 5             |
| 5 | prime    | 7             |
| 7 | prime    | 7             |
| 1 | square   | 7             |
| 4 | square   | 9             |
| 9 | square   | 9             |

keywords

WINDOW,FUNCTION,MAX
© 2023 北京飞轮数据科技有限公司 京ICP备2022004029号 | Apache、Apache Doris 以及相关开源项目名称均为 Apache 基金会商标