groupArray 允许对其进行转换
select 1 uid, 555 time union all select 1, 666 union all select 1, 777
┌─uid─┬─time─┐
│ 1 │ 555 │
│ 1 │ 666 │
│ 1 │ 777 │
└─────┴──────┘
到这里
select uid, groupArray(time) dtime from
(select * from (select 1 uid, 555 time union all select 1, 666 union all select 1, 777) order by uid, time)
group by uid
┌─uid─┬─dtime─────────┐
│ 1 │ [555,666,777] │
└─────┴───────────────┘
和
select uid, arrayJoin(arrayPushBack(arrayPopFront(groupArray(time)), null)) dtime from
(select * from (select 1 uid, 555 time union all select 1, 666 union all select 1, 777) order by uid, time)
group by uid
┌─uid─┬─dtime─┐
│ 1 │ 666 │
│ 1 │ 777 │
│ 1 │ ᴺᵁᴸᴸ │
└─────┴───────┘
select uid, time, atime from (
select uid, groupArray(time) as stime, arrayPushBack(arrayPopFront(stime), null) dtime from
(select * from (select 1 uid, 555 time union all select 1, 666 union all select 1, 777) order by uid, time)
group by uid )
array join stime as time, dtime as atime
┌─uid─┬─time─┬─atime─┐
│ 1 │ 555 │ 666 │
│ 1 │ 666 │ 777 │
│ 1 │ 777 │ ᴺᵁᴸᴸ │
└─────┴──────┴───────┘