At 9:02 AM -0500 11/3/01, Greg Sarsons wrote:
>I haven't succeeded in being able to group by time. My timestamp field
>is yyyy-mm-dd hh:mm:ss. What I would like is have a query that will
>enable me to be to group on events say every 5 minutes.
>I've played around with using time_to_sec(timestamp) to convert all the
>times to seconds and then group by the timestamp to return only distinct
>seconds (timestamp). the timestamp field is multivalued.
Convert to seconds as you're doing, then divide the result by 300 (5 minutes
in seconds) to slot them into 5-minute bins.
You'll probably want TRUNCATE(seconds_val/300,0) to produce integer
division. Otherwise, you'll get a bunch of floating point values
that don't group as you want.