gpt4 book ai didi

php - 找到出现次数最多的值并按其排序

转载 作者:行者123 更新时间:2023-11-29 11:47:43 25 4
gpt4 key购买 nike

+-----------------------+------------------------+
| being_followed | follower |
+-----------------------+------------------------+
| Bob Dylan | B |
| Bob Dylan | A |
| Sam Cooke | X |
| The Beatles | Y |
| Bob Dylan | M |
| Sam Cooke | N |
+-----------------------+------------------------+

现在,我想找到 being_followed 中出现次数最多的值,然后按它排序。 它应该看起来有点像 -

Bob Dylan - 3
Sam Cooke - 2
The Beatles - 1

请不要将此标记为重复。

最佳答案

尝试以下:

select being_followed , count(1) as count
from table
group by being_followed
order by count desc ;

关于php - 找到出现次数最多的值并按其排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34628559/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com