portabletelly Posted June 17, 2007 Share Posted June 17, 2007 Hi, I have a table called call_event. The call_events table has colum called Time_taken. Data in this colum is stored as a decimal vaulue. EG. 4hrs and 15 minutest would be stored as 4.25. I would like to be able to do a mysql query which give a total of all the returned values from a query but Im not quite sure what syntax I need. The query I would like to do is to find out the the total time for a call. I would imagen the query would be somthing like this Query = SELECT Time_Taken FROM call_event WHERE call_id ="$call_ID"; When running this query it will return all the times_taken which have the call_id field = to $call_ID. eg 4.5, 3.25 0.00 5.0 However what do I need to do get the total for all these values eg 4.5 + 3.25 + 0.00 + 5.00 = 12.75 I want to be do a query that will return the value of all the time_Taken added up for example in this case I wanted the query to return 12.75 Is this possible with just a query or do I need to do somthing funky with php to add up all the returned values? Link to comment https://forums.phpfreaks.com/topic/55889-mysql-query-that-adds-total/ Share on other sites More sharing options...
bubblegum.anarchy Posted June 17, 2007 Share Posted June 17, 2007 SELECT sum(Time_Taken) FROM call_event WHERE call_id = $call_ID Link to comment https://forums.phpfreaks.com/topic/55889-mysql-query-that-adds-total/#findComment-276152 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.