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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Summing values from different columns in one table

Author  Topic 

syoselevsky
Starting Member

7 Posts

Posted - 2006-05-19 : 17:18:07
I am trying to add several components of a contest where the values are stored in one table together.

This is what I have:

sum(case when week = @week then (pt1+weekpt1ext+weekpt2+weekpt2bonus) else 0 end) as totweek,

it renders me with a zero value in the table I'm appending the totals to.

Help!

Stacy

nr
SQLTeam MVY

12543 Posts

Posted - 2006-05-19 : 17:28:27
difficult to say without a bit more info.

What's in week and @week?

probably need some example data and the query you are running

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

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-05-20 : 01:58:55
Did any of the column value have NULL value?
Post some sample data and the result you want

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

syoselevsky
Starting Member

7 Posts

Posted - 2006-05-23 : 12:46:39
Thanks for the brain pick! I changed the nulls to zeros and it worked... THANKS!!

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-05-24 : 03:09:14
You can use Isnull(col,0)

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -