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?
我试过了

select count(*) as counted from(select b_id from books) group by b_id


但是它不会只返回40 ...有什么办法可以从查询中获取40

最佳答案

select b_id, count(b_id)
from books
group by b_id
order by count(b_id) desc
limit 1;

关于mysql - mysql查询最大重复值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6404588/

10-13 02:11