mysql每半小時均勻值盤算的sql語句。本站提示廣大學習愛好者:(mysql每半小時均勻值盤算的sql語句)文章只能為提供參考,不一定能成為您想要的結果。以下是mysql每半小時均勻值盤算的sql語句正文
表構造:
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;
統計每半小時均勻值,完成可以以下:
select `timestamp`-`timestamp`% (5*60) , avg(cup) from `instance` group by `timestamp`-`timestamp`% (5*60)
別的還有:
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;