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.
Author |
Topic |
kwikwisi
Constraint Violating Yak Guru
283 Posts |
Posted - 2008-04-07 : 10:30:08
|
HiI have score column(can be 0,1 or 2) and i want to add score based on userid,but i don't want to add if score is "2".On the other hand,i want to add only score is "1".How can i get this target?I use sql2000 enterprise manger. |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-04-07 : 10:34:06
|
[code]Select UserID, Sum(Case when Score <> 2 then Score else 0 end) Score_TotalFrom tablegroup by UserID[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
kwikwisi
Constraint Violating Yak Guru
283 Posts |
Posted - 2008-04-07 : 10:49:05
|
Thanks alot. |
 |
|
kwikwisi
Constraint Violating Yak Guru
283 Posts |
Posted - 2008-04-07 : 21:24:15
|
This is my procedure.But it doesn't work properly.CREATE PROCEDURE [dbo].[sp_overall] ASselect UserID,count(ProblemDescription) as noques,sum(case when Chk<>2 then Chk else 0 end) as scorefrom samplePermAnsgroup by UserIDGO |
 |
|
kwikwisi
Constraint Violating Yak Guru
283 Posts |
Posted - 2008-04-07 : 21:26:47
|
happy coding now it works.Thanks again. |
 |
|
|
|
|