【发布时间】:2019-10-27 10:19:16
【问题描述】:
我想找到每组出现次数最多的值。
我尝试使用 top(k)(column) 但出现以下错误: 列类不在聚合函数下,也不在 GROUP BY 中。
例如: 如果我有带有列(pid,值)的表 test_date
pid, value
----------
1,a
1,b
1,a
1,c
我想要结果:
pid, value
----------
1,a
我试过SELECT pid,top(1)(value) top_value FROM test_data group by pid
I get the error:
Column value is not under aggregate function and not in GROUP BY
我也试过anyHeavy(),但它只适用于出现超过一半情况的值
【问题讨论】:
标签: clickhouse