SQL问题,如何统计出某表中某列中的某值出现的次数.
如某表table1,
... a ...
... 0 ...
... 1 ...
... 2 ...
... 1 ...
... 0 ...
其中a列只有0,1,2三种值,如何统计各值出现的次数,最好弄成这样的
XM CS
0 (0出现的次数)
1 (1出现的次数)
2 (2出现的次数)
[解决办法]
select a as xm,count(a) as cs from table1 group by a