CREATE TABLE test (`id` UInt64, `value` UInt64, `text` String ) ENGINE = Memory INSERT INTO test SELECT number as id, rand64() as value, toString(number) as text FROM system.numbers_mt LIMIT 10000000 SELECT groupArraySorted(100000)(id, value) FROM test SELECT groupArraySorted(100000)(text, value) FROM test SELECT groupArraySorted(100000)((id, text), value) FROM test SELECT groupArraySorted(100000)(text) FROM test DROP TABLE IF EXISTS test