select top 2 * from
(select num,count(0) as countnum from test group by num) tt
order by countnum desc
select top 2 num, count(*) as countn from test group by num order by count(*) desc
select top 2 num,count(num) as fcount from test group by num order by fcount desc
二楼apu510064 的回答是正确的!
MYSQL版本:
SELECT COUNT(num) AS n, id
FROM test
GROUP BY num
ORDER BY n DESC
limit 2
select top 2 num 值,count(num) 次数 from test group by num ORDER BY num