HughbertD Posted March 16, 2008 Share Posted March 16, 2008 Hi all, I have a table which holds information for meetings, in the form of, startDate (timestamp), finishDate(timestamp), meetingCompany (varchar). I want to: Add up the total amount of time spent in meetings for each different company. But only include meetings that are longer than 2 hours long. I haven't a clue how to do this, which is why I have come to you guys, I was told that this was possible in SQL but I had my doubts. If anyone can help I would really appreciate it Link to comment https://forums.phpfreaks.com/topic/96396-adding-timestamps-by-unique-fields-query/ Share on other sites More sharing options...
HughbertD Posted March 16, 2008 Author Share Posted March 16, 2008 So far I have, select timediff(dateTimeFin, DateTimeStart) from calendar; I'm lost as to how to distinguish between meetings over 2 hours and to add them up by each company Link to comment https://forums.phpfreaks.com/topic/96396-adding-timestamps-by-unique-fields-query/#findComment-493384 Share on other sites More sharing options...
aschk Posted March 18, 2008 Share Posted March 18, 2008 I'm assuming each entry has a company id associated with it? SELECT company_id , SUM(TIMESTAMPDIFF(dateTimeFin, DateTimeStart)) as 'diff' FROM calendar WHERE TIMESTAMPDIFF(HOUR, dateTimeFin, DateTimeStart) >= 2 GROUP BY company_id Link to comment https://forums.phpfreaks.com/topic/96396-adding-timestamps-by-unique-fields-query/#findComment-494844 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.