根据数据库表里的记录,查询重复记录最多次的记录
法一:
select top(1)*
from num
where
value=(select value from
(select count(value) as b,value from num group by value)
as bb
where
bb.b=(select max(b) from
(select count(value) as b,value from num group by value) as dd))
法二:
SELECT TOP 1 *
FROM (SELECT value, COUNT(value) AS c
FROM num
GROUP BY value) DERIVEDTBL
ORDER BY c DESC
本文作者:nifeng 来源:http://www.cnblogs.com/nifeng/
CIO之家 www.ciozj.com 微信公众号:imciow