我有一个类似于以下SqlFiddle http://sqlfiddle.com/#!9/f30a65/1/0
的数据库我需要获取该组,但问题是数据在多列上......
例如预期的结果:
VALUE - COUNT或Group By
13 - 2
11 - 1
感谢所有人
答案 0 :(得分:1)
如果您想要分组,可以使用
组合所有列SELECT value, count(value) as count FROM (
SELECT C1 as value FROM TABLE1
UNION ALL
SELECT C2 as value FROM TABLE1
UNION ALL
SELECT C3 as value FROM TABLE1
UNION ALL
SELECT C4 as value FROM TABLE1
UNION ALL
SELECT C5 as value FROM TABLE1
UNION ALL
SELECT C6 as value FROM TABLE1
) all_col GROUP BY value