如何在 ClickHouse 中使用分隔符连接 INT
How to concat INTs with separator in ClickHouse
如何在 CLickHouse 中使用分隔符 ',' 连接 INT 行?
例如我提出一个请求
SELECT ApplicationID , CampaignID
from distributed.advertisers
where AdvertiserID=994 and CampaignID in(318728,318422)
and ActionDate BETWEEN '2021-03-01' and '2021-05-01'
并得到以下结果:
我的目标是获得以下:
我应该如何更改我的请求?
试试这个:
SELECT
arrayStringConcat(arrayMap(x -> toString(x), groupArray(ApplicationId)), ',') AS ApplicationId,
CampaignID
FROM
(
/* emulate the test dataset */
SELECT
data.1 AS ApplicationId,
data.2 AS CampaignID
FROM
(
SELECT arrayJoin([(1, 11), (2, 11), (10, 12), (11, 12)]) AS data
)
)
GROUP BY CampaignID
/*
┌─ApplicationId─┬─CampaignID─┐
│ 1,2 │ 11 │
│ 10,11 │ 12 │
└───────────────┴────────────┘
*/
如何在 CLickHouse 中使用分隔符 ',' 连接 INT 行? 例如我提出一个请求
SELECT ApplicationID , CampaignID
from distributed.advertisers
where AdvertiserID=994 and CampaignID in(318728,318422)
and ActionDate BETWEEN '2021-03-01' and '2021-05-01'
并得到以下结果:
我的目标是获得以下:
我应该如何更改我的请求?
试试这个:
SELECT
arrayStringConcat(arrayMap(x -> toString(x), groupArray(ApplicationId)), ',') AS ApplicationId,
CampaignID
FROM
(
/* emulate the test dataset */
SELECT
data.1 AS ApplicationId,
data.2 AS CampaignID
FROM
(
SELECT arrayJoin([(1, 11), (2, 11), (10, 12), (11, 12)]) AS data
)
)
GROUP BY CampaignID
/*
┌─ApplicationId─┬─CampaignID─┐
│ 1,2 │ 11 │
│ 10,11 │ 12 │
└───────────────┴────────────┘
*/