mysql 查询最大重复值 [英] mysql query for maximum duplicate value
本文介绍了mysql 查询最大重复值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
b_id | s_id | doi | dos | charge |
+------+------+------------+------------+--------+
| 10 | 3 | 0000-00-00 | 0000-00-00 | 200 |
| 10 | 2 | 0000-00-00 | 0000-00-00 | 200 |
| 20 | 1 | 0000-00-00 | 0000-00-00 | 200 |
| 30 | 2 | 0000-00-00 | 0000-00-00 | 200 |
| 40 | 4 | 0000-00-00 | 0000-00-00 | 200 |
| 40 | 5 | 0000-00-00 | 0000-00-00 | 200 |
| 70 | 5 | 0000-00-00 | 0000-00-00 | 200 |
| 40 | 4 | 0000-00-00 | 0000-00-00 | 200 |
mysql 查询查找重复最长时间的 b_id?我试过了
mysql query to find b_id which repeats for maximum time? i tried
select count(*) as counted from(select b_id from books) group by b_id
但它不会只返回 40...有什么办法可以从查询中得到 40
but it would not return just 40...Is there any way i could just get 40 from the query
推荐答案
select b_id, count(b_id)
from books
group by b_id
order by count(b_id) desc
limit 1;
这篇关于mysql 查询最大重复值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文