我想查询前 3 位贡献作者,即他们撰写的页面/帖子最多。我会通过与每一行相关联的用户的 session_id 选择数据,即他们写的页面。我想选择并排序数据库中行数最多的前 3 个人。我该如何查询?我在想...
SELECT DISTINCT user_id
FROM music_spot
WHERE (need a condition here)
ORDER BY (the person who contributed the most pages to the third
LIMIT 3
我怎么能做这样的事情呢?谢谢。
最佳答案
SELECT user_id
FROM music_spot
WHERE session_id = 123
ORDER BY count(user_id) desc
group by user_id
LIMIT 3
关于mysql - 执行查询以获取数据行中 user_id id 的前 3 次出现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9714982/