Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save den-crane/f3a6a7c1f8beb61e2632729096be3fb3 to your computer and use it in GitHub Desktop.
Save den-crane/f3a6a7c1f8beb61e2632729096be3fb3 to your computer and use it in GitHub Desktop.
drop table tg
create table tg (a Int64, b Int64, c Int64) Engine = TinyLog;
insert into tg values (1,1433419200,15),(1,1433332800,23),(1,1433246400,41),(1,1433160000,55),
(1,1432900800,24),(2,1433419200,52),(2,1433332800,23),(2,1433246400,39),
(2,1433160000,22),(3,1433419200,11),(3,1433246400,58)
select a,tupleElement(x,1) b, tupleElement(x,2) c from (
select a,arrayJoin(arraySlice(groupArray(tuple(b,c)),1,3)) x from tg group by a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment