Page 1 of 1

Group by---- Problem

Posted: Thu Sep 20, 2007 1:55 am
by sandy1028
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


[syntax="sql"]select avg(bw_util) from `tablename` where `fieldname`< now() and `fieldname` > date_sub(now(),interval 1 day) group by hour(timestamp) order by `fieldname` desc

The above query is used to take the average of hourly data.

How to group by minutes


feyd | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu Sep 20, 2007 9:27 am
by mezise
Hi,
MySQL has a MINUTE() function:

Code: Select all

SELECT MINUTE(NOW());
Is that what you need?

Michal