gpt4 book ai didi

mysql - 按 UNION ALL 中的值分组的计数

转载 作者:行者123 更新时间:2023-11-29 12:25:34 24 4
gpt4 key购买 nike

我在 mySQL 中有以下查询

`SELECT * FROM (select assoc1 from fab_cbd where tournament = 65   
union all
select assoc2 from fab_cbd where tournament = 65) x`

使用它我可以获得包含这两列值的完整列表。我想要做的是按这些值进行分组并计算出现次数。

提前致谢。

最佳答案

然后添加分组依据:

SELECT assoc, count(*)
FROM (select assoc1 as assoc from fab_cbd where tournament = 65
union all
select assoc2 from fab_cbd where tournament = 65
) x
GROUP BY assoc;

关于mysql - 按 UNION ALL 中的值分组的计数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28382640/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com