Ok thanks now I'd like to do a sum on several intervals.
Let's say we have these records:
Code:
+---------------------+---------------------+
| start_time | end_time |
+---------------------+---------------------+
| 2006-07-01 10:00:00 | 2006-07-01 11:00:00 | <- duration: 1h
| 2006-06-10 12:00:00 | 2006-06-10 15:30:00 | <- duration: 3.5h
| 2006-05-12 09:00:00 | 2006-05-12 16:00:00 | <- duration: 7h
| 2005-08-05 08:00:00 | 2005-08-05 10:00:00 | <- duration: 2h
+---------------------+---------------------+
I suppose this doesn't work:
Code:
SELECT
SUM(TIMEDIFF(end_time, start_time)) AS "total"
FROM
table
WHERE
YEAR(start_time) = 2006
GROUP BY
YEAR(start_time)
Here is the result that I'd like to get:
Code:
+----------+
| total |
+----------+
| 11:30:00 |
+----------+