Group mysql query by 15 min intervals

前端 未结 10 829
醉梦人生
醉梦人生 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:50

    Try this , grouping of records of 15 minutes interval, you can change 15*60 to the interval in seconds you need

    SELECT sec_to_time(time_to_sec(datefield)- time_to_sec(datefield)%(15*60)) as intervals from tablename
    group by intervals
    

提交回复
热议问题