0

我有一个包含以下数据的 MySQL 表:

filer            time               name        size-percentage-used  disk-count
filer01a  2012-01-19 05:59:02  aggr0                     96               3
filer01a  2012-01-19 05:59:02  ncna01a_aggr01            97              42
filer01a  2012-01-19 05:59:02  ncna01a_aggr02            96              22
filer01a  2012-01-19 05:59:02  ncna01a_aggr03             0              22
filer01a  2012-01-19 12:00:01  aggr0                     96               3
filer01a  2012-01-19 12:00:01  ncna01a_aggr01            97              42
filer01a  2012-01-19 12:00:01  ncna01a_aggr02            96              22
filer01a  2012-01-19 12:00:01  ncna01a_aggr03             0              22
filer01a  2012-01-20 12:00:01  aggr0                     96               3
filer01a  2012-01-20 12:00:01  ncna01a_aggr01            97              42
filer01a  2012-01-20 12:00:01  ncna01a_aggr02            96              22
filer01a  2012-01-20 12:00:01  ncna01a_aggr03             0              22
filer01a  2012-01-21 12:00:01  aggr0                     96               3
filer01a  2012-01-21 12:00:01  ncna01a_aggr01            97              42
filer01a  2012-01-21 12:00:01  ncna01a_aggr02            96              22
filer01a  2012-01-21 12:00:01  ncna01a_aggr03             0              22
filer01a  2012-01-22 12:00:02  aggr0                     96               3
filer01a  2012-01-22 12:00:02  ncna01a_aggr01            97              42
filer01a  2012-01-22 12:00:02  ncna01a_aggr02            96              22
filer01a  2012-01-22 12:00:02  ncna01a_aggr03             9              22
...

申报者名单从 01 到 102,时间每天更新。我需要一个查询,它将提供 filer、sum( disk-count) 作为 DDM、size-percentage-used 和 max(time)。

我正在寻找的输出将是:

 filer    DDMs     size-percentage-used  time                
 ncna01a  89                         96  2012-01-19 05:59:02
 ncna01a  89                         96  2012-01-19 05:59:02
 ncna02a  89                         96  2012-01-19 05:59:02
 ...

我是一个完整的 MySQL 新手,感谢任何和所有的帮助。

4

1 回答 1

0

据我了解,您将需要类似以下查询的内容:

SELECT SUM(disk-count) AS ddms, 
       AVG(size-percentage-used) AS percent_used, 
       MAX(time) as max_time 
FROM filers 
GROUP BY filer
于 2013-03-27T20:28:55.547 回答