FROM (SELECT number
, multiIf(
number / 10 <= 1, 10,
number / 20 <= 1, 20,
number / 30 <= 1, 30,
number / 40 <= 1, 40, null) as type_number
FROM system.numbers
LIMIT 49)
WHERE type_number is not null
GROUP BY type_number
ORDER BY type_number
)
;
-- запрос 2
SELECT arrayConcat(
[0,1,2,3,4,5,6,7,8,9,10],
[11,12,13,14,15,16,17,18,19,20],
[21,22,23,24,25,26,27,28,29,30],
[31,32,33,34,35,36,37,38,39,40])
as all_numbers;
Добрый день, подскажите есть ли возможность при группировке конкатенировать массив
на примере чтоб в запросе 1 был результат как в запросе 2 ?
SELECT arrayFlatten(groupArray(group_number)) as all_numbers FROM (SELECT groupArray(number) as group_number FROM (SELECT number , multiIf( number / 10 <= 1, 10, number / 20 <= 1, 20, number / 30 <= 1, 30, number / 40 <= 1, 40, null) as type_number FROM system.numbers LIMIT 49) WHERE type_number is not null GROUP BY type_number ORDER BY type_number )
еще можно groupArrayArray вместо groupArray
Обсуждают сегодня