
表名: table
字段名: a b c d e f
数据: 1 2 1 1 2 3
+++++++++++++++++++++++++++++++++++++++++++++++++
求,表table中数据为“1”的个数有多少?
数据为“2”的个数有多少?
数据为“3”的个数有多少?
------解决思路----------------------
列转行,然后再汇总,11g以上版本可以考虑使用unpivot
select value,count(1) from(
select a as value from table1
union all
select b as value from table1
……
)group by value