Jump to content

Summing columns


cpd

Recommended Posts

Say for example i have a table in my database like this:

 

id    value

1      5

2      6

3      1

4      8

 

And i want to total the "value" column. How do i sum it and is it a function like mysql_num_rows()?

Link to comment
Share on other sites

Will that not just get the amount EG in this case 4 because theres 4 rows.

 

I want the sum of the values in each row not the amount of rows?

 

Umm no...

 

SELECT SUM(value) as valueSum FROM tbl_name WHERE ID IN(1,2,3,4) GROUP BY value

 

Will return valueSum = 20

 

 

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.

Guest
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.