> -----Original Message-----
> From: Roger Baklund [mailto:[EMAIL PROTECTED]
> Sent: 03 December 2004 16:03
> To: [EMAIL PROTECTED]
> Cc: James Nunnerley
> Subject: Re: sum queries
> 
> James Nunnerley wrote:
> > I'm trying to create a table, and ultimately a graph, out of some syslog
> > data.
> >
> >
> >
> > I have a table with the following info in it:
> >
> > Time (unixtime stamp), bytes rcvd and bytes sent
> >
> >
> >
> > I want to create a sql statement that group the data over a certain
> period
> > of time, and produces the following table:
> 
> You don't tell us what this "certain period" is, in general you use date
> & time functions to manipulate time. If your period was one hour, you
> could use something like this:

Apologies, I was hoping that the time period would be "dynamic", as it's
being called from a php script, which might choose an overall period of 7
days, split into 3 hour periods, or 24 hours, split into half hour periods.

> 
> select date_format(ts,"%Y-%m-%d %H") period,sum(rcvd),sum(sent)
>    from mytable
>    group by period;

So the below query above will allow me to group by hour - which is quite
useful - is there anyway of grouping by say 3 hour periods?

Thanks
James

> 
> <URL: http://dev.mysql.com/doc/mysql/en/Date_and_time_functions.html >
> 
> --
> Roger
> 



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to