如何查询“SQL计算表中一个列中各数的出现次数”?

如题所述

select countB)from A group by B order by B

SQL语句就可以做了,例检索表格aaa,添加一列“re_num”,显示a列值重复的次数,

次数为表格按a列分组计算记录数:

select a,count(a) as 're_num' from aaa group by a,

select a1.a2.re_num from 

aaa a1 

join 

(select a,count(a) as 're_num' from aaa group by a) a2 

on a1.a = a2.a;

select sum(datac.COUNT_VALUE)

from T_JL_COUNT_DATA datac

, T_JL_XC_RESULT a

where datac.COUNT_NO=45 and a.id=datac.RESULT_ID。

温馨提示:答案为网友推荐,仅供参考