Skip to content

Instantly share code, notes, and snippets.

@Addvilz
Created June 30, 2012 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Addvilz/3025873 to your computer and use it in GitHub Desktop.
Save Addvilz/3025873 to your computer and use it in GitHub Desktop.
Excelent way to calculate durations of multiple intervals grouped by id
SELECT SUM(TIME_TO_SEC(TIMEDIFF(`to`,`from`))) as `spent` FROM `intervals` GROUP BY `id`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment