我有一张桌子,上面有几千张这样的唱片:

[Row]    ActionTime              Score
=======================================
[#1]   2011-08-06 12:30:15       30
[#2]   2011-08-06 12:30:20       50
[#3]   2011-08-06 12:30:47       40
[#4]   2011-08-06 12:40:12       30
[#5]   2011-08-06 12:40:28       10
[#5]   2011-08-06 12:45:12       60

我想在几分钟内把数据分组,找出每组的最大分数。
结果是这样的:
[Row]  ActionTime (without "second")          Score
========================================================
[#1]   2011-08-06 12:30:00                     50
[#2]   2011-08-06 12:40:00                     30
[#3]   2011-08-06 12:45:00                     60

我如何通过MySQL做到这一点?
谢谢!

最佳答案

select
date_format(actiontime,'%Y-%m-%d %H:%i:00') as act_time,
max(score) as greater
from table
group by act_time

关于mysql - MySQL:按日期时间分组记录,忽略“秒”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6981973/

10-16 18:48