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
 running totals

Author  Topic 

tjonas
Starting Member

17 Posts

Posted - 2015-01-16 : 13:20:24
I am wondering how I would add totals. I need to add all the sale_id by person. It should look like below. I can pull in the sale_name and sale_id but i'm unsure how to create a column that totals like sale_num below. Thanks.
sale_Name sale_id sale_num
Jim Thomas 157452
Jim Thomas 153352
Jim Thomas 198762
Jim Thomas 3
Bill Simpson 254854
Bill Simpson 265782
Bill Simpson 233122
Bill Simpson 257411
Bill Simpson 4

sz1
Aged Yak Warrior

555 Posts

Posted - 2015-01-21 : 09:08:46
Select sale_Name, Sum(sale_id) sale_num
From Salestable
Group By sale_name,sale_id
Order By sale_name asc

We are the creators of our own reality!
Go to Top of Page
   

- Advertisement -