Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Returning serveral sums from same table

Author  Topic 

allanurban
Starting Member

21 Posts

Posted - 2012-11-02 : 11:44:04
Hello all

I have a table with three colums. First one is unique id. The second and third are a varchar with names and a int with numbers.

There er serveral entries of each name alle with different numbers. I want to return a resultset with a row for each name and then the sum of all numbers for that specific name.

Anyone with a suggestion on how to solve it?

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-11-02 : 11:50:16
select name, sum(number)
from tbl
group by name


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

allanurban
Starting Member

21 Posts

Posted - 2012-11-02 : 12:16:23
Oh that's neat. Thank you very much!
Go to Top of Page
   

- Advertisement -