开发者

mysql query for maximum duplicate value

 b_id | s_id | doi        | dos        | charge |
+------+------+------------+------------+-开发者_如何学C-------+
|   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 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

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;


SELECT COUNT(*) Counted FROM `books` GROUP BY `b_id` ORDER BY COUNT(*) DESC LIMIT 1

Ah, too late, but I got the DESC in, I think that's needed :-)


SELECT COUNT(*) `counted` FROM `books`
GROUP BY `b_id` 
ORDER BY `counted` DESC 
LIMIT 0,1
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜