+-----------------------+------------------------+
| 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 ;

10-08 09:05