I have this mysql query:
SELECT CONCAT(u.lastname, ', ', u.firstname) AS Name, start.timestamp start, end.timestamp end, timediff(end.timestamp, start.timestamp) duration from user u, user_group ug, ( select *, ( select event_id from event L2 where L2.timestamp>L1.timestamp and L2.user_bannerid=L1.user_bannerid order by timestamp limit 1 ) stop_id from event L1 ) start join event end on end.event_id=start.stop_id where start.status='In' and end.status='Out' and u.user_bannerid = start.user_bannerid and ug.user_bannerid = u.user_bannerid and ug.group_id = start.group_id
And he shows something like this:
+----------------------------------------------------+---------------+ | Name | start | end | duration | +----------------------------------------------------+---------------+ | User | 2011-11-24 02:12:05 | 2011-11-24 02:12:20 | 00:00:15 | | User | 2011-11-28 21:46:54 | 2011-11-28 21:53:01 | 00:06:17 | +----------------------------------------------------+---------------+
But I want the last line to display the total amount of duration, for example:
+----------------------------------------------------+---------------+ | Name | start | end | duration | +----------------------------------------------------+---------------+ | User | 2011-11-24 02:12:05 | 2011-11-24 02:12:20 | 00:00:15 | | User | 2011-11-28 21:46:54 | 2011-11-28 21:53:01 | 00:06:17 | | | | | 00:06:32 | +----------------------------------------------------+---------------+
Can someone help me modify the query to show the amount of duration in the next line?
source share