如何在sql中显示列中重复次数最高的字段?
例如,如果一列包含:
杰克 杰克 约翰 约翰 约翰
如何显示上列中的最大重复字段(即)约翰?
select chairman
from mytable
group by chairman
HAVING COUNT(*) = (
select TOP 1 COUNT(*)
from mytable
group by chairman
ORDER BY COUNT(*) DESC)
select name from persons
group by name
having count(*) = (
select count(*) from persons
group by name
order by count(*) desc
limit 1)