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.
这是桌子。它按点 (desc) 和 id 排序
id name points 1 ed 10 1 ed 9 2 jim 14 2 jim 8 2 jim 4 3 mike 11
这是我正在寻找的结果:
id name points 1 ed 10 2 jim 14 3 mike 11
如何才能做到这一点?基本上,我只想列出每个名称的最高点行并过滤掉其他行。
你可以尝试这样的事情:使用MAX()函数
MAX()
SELECT id, name, MAX(points) FROM your_table GROUP BY id, name ORDER BY points desc
尝试这个:
select id,name,max(points) from table1 group by id