MySQL Forums
Forum List  »  Newbie

Re: Group Data by Timerange?
Posted by: Felix Geerinckx
Date: May 09, 2005 10:55AM

Christian Brosius wrote:

> In my Database, there is a datetime-field and fields for inOctets and outOctets.
> every Second, there is a row added with new values.
>
> I want to create a new table, where the Values are summarized in intervals of a minute
> or a hour with a mysql-query on the orginal table.

Your first task is to create a query that summarizes into intervals. E.g.

SELECT
DATE_FORMAT(ts, '%Y-%m-%d %h:%i') AS I
SUM(inOctects),
SUM(outOctects),
FROM foo
GROUP BY I;

Using the INSERT INTO ... SELECT ... syntax, you can then insert these summary records in another table (see http://dev.mysql.com/doc/mysql/en/insert.html)

--
felix
Please use BBCode to format your messages in this forum.

Options: ReplyQuote


Subject
Written By
Posted
Re: Group Data by Timerange?
May 09, 2005 10:55AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.