problems with sum...

Please support our MS SQL advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2009
Posts: 2
Reputation: almis is an unknown quantity at this point 
Solved Threads: 0
almis almis is offline Offline
Newbie Poster

problems with sum...

 
0
  #1
Apr 3rd, 2009
Hi!

I have this table:

id table #people
1 ...1 .........3
2 ...1 .........5
3 ...4 .........2
4 ...3 .........5
5 ...1......... 2

i want to obtain the sum of people sitting per table.

hope you can help me...
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,438
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 510
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: problems with sum...

 
0
  #2
Apr 3rd, 2009
So you would just need to "group by" table and use another aggregate function to sum them up. I bet you can find that function pretty easily.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 146
Reputation: Stylish is an unknown quantity at this point 
Solved Threads: 14
Stylish's Avatar
Stylish Stylish is offline Offline
Junior Poster

Re: problems with sum...

 
0
  #3
Apr 3rd, 2009
  1. SELECT TABLE, sum(people)
  2. FROM TABLES
  3. GROUP BY TABLE

All aggregate functions (sum, max, min, avg, etc) must include a GROUP BY including all columns up-to the aggregate.

If this is a school assignment, I suggest you crack the books and spend time in the lab.
Last edited by Stylish; Apr 3rd, 2009 at 4:13 pm.
I NEED AN ADULT!
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 2
Reputation: almis is an unknown quantity at this point 
Solved Threads: 0
almis almis is offline Offline
Newbie Poster

Re: problems with sum...

 
0
  #4
Apr 3rd, 2009
thank you all...
I was doing something really stupid.

Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the MS SQL Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC