《MYSQL数据库mysql每半小时平均值计算的sql语句》要点:
本文介绍了MYSQL数据库mysql每半小时平均值计算的sql语句,希望对您有用。如果有疑问,可以联系我们。
MYSQL学习表结构:
MYSQL学习
CREATE TABLE `instance` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`timestamp` int(10) unsigned DEFAULT NULL,
`cpu` decimal(8,3) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
MYSQL学习统计每半小时平均值,实现可以如下:
MYSQL学习
select `timestamp`-`timestamp`% (5*60) , avg(cup)
from `instance`
group by `timestamp`-`timestamp`% (5*60)
MYSQL学习另外还有:
MYSQL学习
SELECT queueName, HOUR(dt) AS h, FLOOR(MINUTE(dt) / 30) AS v ,
avg(memoryUsed), sum(memoryUsed), count(memoryUsed)
from queue_resource
where dt>='2014-04-14 00:00:00'
GROUP BY h, v, queueName;
转载请注明本页网址:
http://www.vephp.com/jiaocheng/4903.html