Here’s a table I have with DATETIMEs in and out. I’d like to sum the TIMEDIFFs per p_ID and group them by p_ID.
t_ID p_ID t_IN t_OUT
1 1 2011-07-13 18:54:56 2011-07-13 20:16:12
2 1 2011-07-14 09:26:56 2011-07-14 09:46:02
3 1 2011-07-14 10:06:39 2011-07-14 10:56:31
4 3 2011-07-14 13:07:04 2011-07-14 13:58:35
I’ve tried a few MySQL commands to no avail… My last attempt looked like this:
SELECT p_ID, TIME_FORMAT(SUM(TIMEDIFF(t_OUT,t_IN)),'%H:%i') AS time FROM timeclock GROUP BY p_ID
I’m guessing my command is not summing per record per p_ID… Any help?
Figured it out: