sql 怎么取count(*)中的最大值?
nameaaaabbccccselectcount(name),namefromtable之後出现namecount()a4b2c4而我其实只想找出出现最多次的name即...
name
a
a
a
a
b
b
c
c
c
c
select count(name),name
from table
之後出现
name count()
a 4
b 2
c 4
而我其实只想找出出现最多次的name
即c和a
但又不能输入SQL为max(count(name))
我应该如何写这SQL..??? 展开
a
a
a
a
b
b
c
c
c
c
select count(name),name
from table
之後出现
name count()
a 4
b 2
c 4
而我其实只想找出出现最多次的name
即c和a
但又不能输入SQL为max(count(name))
我应该如何写这SQL..??? 展开
3个回答
展开全部
select name, count(name) from t group by name
having count(name)=
(select max(a.cou) from (select count(name) as cou from t group by name) a )
having count(name)=
(select max(a.cou) from (select count(name) as cou from t group by name) a )
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select top 1 name,count(name) from table group by name order by count(name) desc
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
可以试试max
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询