我有一个包含以下数据的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,每天更新时间。我需要一个查询,它将提供文件管理器,总和(disk-count
)作为DDM,使用大小百分比和最大(时间)。
我正在寻找的输出将是:
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新手,感谢所有人的帮助。
答案 0 :(得分:0)
根据我的理解,您将需要类似以下查询的内容:
SELECT SUM(disk-count) AS ddms,
AVG(size-percentage-used) AS percent_used,
MAX(time) as max_time
FROM filers
GROUP BY filer