943,608 Members | Top Members by Rank

Ad:
  • MS SQL Discussion Thread
  • Unsolved
  • Views: 924
  • MS SQL RSS
Apr 3rd, 2009
0

problems with sum...

Expand Post »
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...
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
almis is offline Offline
2 posts
since Apr 2009
Apr 3rd, 2009
0

Re: problems with sum...

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.
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 838
Posting Genius
Ezzaral is offline Offline
6,756 posts
since May 2007
Apr 3rd, 2009
0

Re: problems with sum...

MS SQL Syntax (Toggle Plain Text)
  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.
Reputation Points: 44
Solved Threads: 19
Junior Poster
Stylish is offline Offline
148 posts
since May 2007
Apr 3rd, 2009
0

Re: problems with sum...

thank you all...
I was doing something really stupid.

Reputation Points: 10
Solved Threads: 0
Newbie Poster
almis is offline Offline
2 posts
since Apr 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MS SQL Forum Timeline: Need help with SQL update query
Next Thread in MS SQL Forum Timeline: Row postion in sql 2005





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC