使用count函数即可。
例如:
表名test
id name
1 a
1 b
1 f
2 c
2 d
3 e
select id from test group by id having count(*)=
(select top1 count(*) as counts from test group by id order by counts desc)
就说个简单的吧,排序法,此方法并不严谨,也许是楼主问题并不严谨,10-30名如果出现的频率都是20次,则有的将显示不出来。
SELECT TOP 20 PartID,COUNT(1) v_SUM FROM dbo.Ware01F GROUP BY PartID ORDER BY COUNT(1) DESC
SELECT TOP (20) PPNAME, COUNT(PPNAME) AS Top20
FROM NAME
GROUP BY PPNAME
ORDER BY Top20 DESC
出现次数最多的? 用group by PPNAME
查询 按照count字段排序
select top 20 PPNAME, count(*)
from NAME
group by PPNAME