id是主键,time是索引,在不影响索引的情况下查询
floor(now())返回的是当前时间格式的数字,如20181218130000
floor(time/500)*500去掉秒数并五分钟显示
select DATE_FORMAT(FLOOR(time/500)*500,'%Y-%m-%d %H:%i') tt,AVG(cpuUsageRate) cpuUsageRateAVG from message where message_id>=(select message_id from message where time=DATE_SUB(NOW(),INTERVAL 1 DAY)) GROUP BY tt