我在mySQL中有以下查询
`SELECT * FROM (select assoc1 from fab_cbd where tournament = 65
union all
select assoc2 from fab_cbd where tournament = 65) x`
使用这个,我得到包含这两列值的完整列表。我想要做的是按这些值进行分组并计算出现次数。
提前致谢。
答案 0 :(得分:1)
然后添加group by
:
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;