Jump to content

mysql query that adds total


Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.