我有一个名为'testing‘的表,有3列,即用户,分数,时间,因为’时间‘是唯一的,用户,分数与不同的分数重复。如下所示
user | score | time
----------------------------
535 | 17 | 1279170280
535 | 1 | 1279170693
100 | 55 | 1279171361
100 | 30 | 1279171412
535 | 2 | 1279173412
595 | 4 | 1279173539
595 | 22 | 1279173571
595 | 50 | 1279173775现在,我如何才能获得高分数的用户。请帮帮忙..。
发布于 2010-07-15 16:12:13
下面将为您提供每个用户的最高分列表。
select user, max(score) from table group by user如果你想进入前10名,只需添加限制即可
select user, max(score) from table group by user limit 10发布于 2010-07-15 16:12:59
SELECT
user,
max(score)
FROM
testing
GROUP BY
user这个应该可以了..
发布于 2010-07-15 16:31:29
select *
from testing join
(select max(score) score, user
from testing
group by user) high using (score, user)这应该会给你最高分,user#和得分的时间,如果这是你想要的。如果不需要时间,则只能执行内部查询
https://stackoverflow.com/questions/3253625
复制相似问题