Jump to content


calcuate the total number from a particular column

  • Please log in to reply
1 reply to this topic

#1 DanielStead

  • Members
  • Pip
  • Newbie
  • 6 posts

Posted 12 December 2005 - 10:25 AM

hi can anyone suggest a link or a method to how i would do this?

I want to do an sql statement that selects say for example the column pages and adds up all the pages in the column for example

id pages
1 2
2 4
3 8
4 10

The total number of pages should then be 24 (2+4+8+10)

anyone got any ideas seems simple but cant find anywhere that tells me how to do it

#2 fenway

  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 24 December 2005 - 02:38 AM

Try using the SUM() function:

SELECT SUM(pages) FROM pages_table

Hope that helps.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users