Mysql
 sql >> Database >  >> RDS >> Mysql

Conta quante voci ci sono in un database a intervalli di 5 minuti

SELECT concat( date_format(datetime,'%Y-%m-%d %k:')
             , lpad(floor(minute(datetime)/5)*5,2,'0')
             , ':00'
             ) datetime
     , location
     , count(1)
  FROM packet_locations
  GROUP BY date(datetime)
         , hour(datetime)
         , floor(minute(datetime)/5)
         , location