开窗函数

select
id,cnt,
sum(cnt) over w as sum_cnt
from
(
select 'a' as id, 1 as cnt
union all
select 'a' as id, 9 as cnt
union all
select 'a' as id, 4 as cnt
union all
select 'a' as id, 2 as cnt
) A
WINDOW w AS (PARTITION BY id order by cnt rows between unbounded preceding and unbounded following)
Settings allow_experimental_window_functions = 1

posted @ 2021-09-02 15:07  muyue123  阅读(95)  评论(0编辑  收藏  举报