【发布时间】:2020-07-09 11:49:23
【问题描述】:
使用 Clickhouse 数据库计算表中矩阵的逐项总和的正确和最快的方法是什么?
我找到了这样的解决方案。但在我看来,这还不够理想。 还有一个,我需要为一维的每个元素指定 sumForEach()。
select array(sumForEach(matrix[1]), sumForEach(matrix[2])) from (
select 1 as id, [[1,3], [2,4]] as matrix
union all
select 2 as id, [[2,4], [3,5]] as matrix
union all
select 3 as id, [[1,2], [1,0]] as matrix
)
因此,我希望看到一行带有结果矩阵
┌─m─────────────┐
│[[4,9],[6,9]] │
└───────────────┘
【问题讨论】:
标签: arrays matrix multidimensional-array clickhouse