-1

我有一个包含日志数据的表,格式如下:

Date        Time    Device  Configuration
01.01.2012  12.00   8193    12345
01.01.2012  12.15   8193    12345
01.01.2012  12.35   8193    22375
01.01.2012  12.37   7191    32335

我每天都需要每个设备的最大配置:

Date        Device  Configuration
01.01.2012  8193    22375
01.01.2012  7191    32335

我可以创建 Dates-devices 的叉积来获取所有 Date-device 组合,
但是如何找到每个 Date-Device 对最大配置

4

2 回答 2

2

只需按日期和设备分组,获取 MAX 即可。

SELECT Date, Device, MAX(Configuration) AS Configuration
FROM logData
GROUP BY Date, Device
于 2012-09-14T07:54:42.770 回答
1
select `date`,`Device`,max(Configuration) as MaxConfig from logData
group by `date`,`Device`
于 2012-09-14T08:05:32.857 回答