Group mysql query by 15 min intervals

前端 未结 10 725
醉梦人生
醉梦人生 2020-11-27 03:09

I\'ve got a monitoring system that is collecting data every n seconds (n is approximately 10 but varies). I\'d like to aggregate the collected data by 15 minute intervals.

10条回答
  •  有刺的猬
    2020-11-27 03:47

    SELECT   FLOOR(UNIX_TIMESTAMP(timestamp)/(15 * 60)) AS timekey
    FROM     table
    GROUP BY timekey;
    

提交回复
热议问题