Skip to content

Instantly share code, notes, and snippets.

@inv2004
Created June 2, 2019 19:46
Show Gist options
  • Save inv2004/c35a43e66d519bba12263dd0a34a4bd8 to your computer and use it in GitHub Desktop.
Save inv2004/c35a43e66d519bba12263dd0a34a4bd8 to your computer and use it in GitHub Desktop.
create table t1 (k String, v UInt64) ENGINE MergeTree() partition by tuple() ORDER BY k
insert into t1 select 'a' as k, number as v from system.numbers limit 5
insert into t1 select 'b' as k, number as v from system.numbers limit 10
select k, arrayCumSum(groupArray(v)) as g from t1 group by k
select * from (select k, v, arrayCumSum(groupArray(v) as v) as g from t1 group by k) array join v, g
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment