Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可以说我的桌子看起来像:
username userid a1 1 a1 1 a1 1 b2 2 c2 3 d2 3
最受欢迎的用户名:a1
a1
如何找到表中最受欢迎的项目?
SELECT username, count(*) AS frequency FROM your_table GROUP BY username ORDER BY frequency DESC LIMIT 1
将产生一行:
username | frequency ---------+---------- a1 3