02
May
13

Group SQL query by N minutes

Found this neat SQL script by Nicolas Poggi that allow to group time by N period like 5,10 or 30 minutes.

http://web.performancerasta.com/group-by-a-sql-query-by-n-minutes/

((60/N) * HOUR(date_time_field ) + FLOOR( MINUTE(date_time_field) / N ))

Advertisements

0 Responses to “Group SQL query by N minutes”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: