0

好的,所以我的原件是这个

select people, count(*) 
from table
group by people

但是有些人有多个人,所以这个聚合不会给你 A、B、C 的纯计数,而且每次迭代

A 10
B 5
A, B 1
A, C 2
C 15
A, B, C 3

等等

这可以获取遗留 sql 中个人的完整列表

select split(people,",") as person
from table

但我不能在上面使用 group by

select split(people,",") as person, count(*)
from table
group by person

给出错误

无法按聚合分组。

我觉得解决方案是一个子查询,不知何故,但我不知道如何执行它

4

1 回答 1

1

尝试用外部查询换行

select person, count(*)
from(
    select split(people,",") as person
    from table
) t
group by person
于 2019-08-15T16:53:01.207 回答