I'm trying to work out an SQL statement for MySQL. I have a series of stats for a range of servers that are reported on a half hourly basis. I have a stats table with columns similar to this:
server varchar(64),
time datetime,
bytesIn int,
bytesOut int
Now, I want to generate a series of reports that collate all of the bytesIn and bytesOut on a either 1 hour or 1 day period across all servers. ie. I know I need SUM(bytesIn) as bytesIn, SUM(bytesOut) as bytesOut, but don't know how to 'clump' all of the times into hourly/daily buckets and also return that 'clumped' time. That is, the returned data should look something like this:
Time,bytesIn,bytesOut
12:00,1024,2048
13:00,4096,8192
etc
I know this should be simple, but I'm lost. Can anyone help?