如何选择具有最大条目数的用户?

时间:2015-04-07 09:38:37

标签: mysql sql

您能否帮我提出一个查询,向用户显示最多条目数。

enter image description here

这应该显示" Benedicto Dalondonan"因为他的请求数量最多。

谢谢你们。

5 个答案:

答案 0 :(得分:3)

您可以使用

执行此操作
select requestor,count(req_id) 
from table_name 
group by requestor 
order by count(req_id) desc limit 1;

答案 1 :(得分:0)

试试这个:

select * from `table` group by requestor having max(count(*))

答案 2 :(得分:0)

试试这个:

SELECT requester, COUNT(*) as c 
FROM table GROUP BY requester
having max(count(*))

答案 3 :(得分:0)

SELECT requestor,count(req_id)total
FROM table_name
GROUP BY requestor
HAVING MAX(COUNT(*))
ORDER BY count(req_id) desc limit 1

答案 4 :(得分:0)

只是一点调整

SELECT name 
FROM  (SELECT Count(*) AS cnt, name 
       FROM   `test` 
       GROUP  BY name 
       ORDER  BY cnt DESC 
       LIMIT  1) AS test;