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
 sum columns instead of displaying duplicate record

Author  Topic 

rob41
Yak Posting Veteran

67 Posts

Posted - 2010-07-22 : 16:07:48
I am trying to get sql to sum the other amount for ship# and have it look like the colum titled after. Any suggestions are always greatly appreciated.

before
load# ship# other_amt
490000554 S00000653 79.1300
490000554 S00000653 79.1300
490000555 S00000654 79.1400
490000555 S00000654 79.1400

after
load# ship# other_amt
490000554 S00000653 158.26
490000555 S00000654 158.28

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-07-22 : 16:21:01
select
load,
ship,
sum(other_amt) as other_amt
from your_table
group by load,ship


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

rob41
Yak Posting Veteran

67 Posts

Posted - 2010-07-22 : 16:30:02
Thanks so much for the help solution works like a charm!
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-07-22 : 16:32:05
welcome


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -