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 |
|
whitmoj
Yak Posting Veteran
68 Posts |
Posted - 2009-01-12 : 05:35:55
|
I have a sum calc using the following SUM (Presented - TotalHandled) AS AbandonedByFunction, which works fine untill the presented row is 0 then i get a minus number. Can Any one tell me if there is an if statement I can put in front of my Calculation. Many Thanks WhitmojWhitmojIf you are in a hurry you will never get there |
|
|
Jai Krishna
Constraint Violating Yak Guru
333 Posts |
Posted - 2009-01-12 : 05:43:16
|
| if(presented>TotalHandled)SUM (Presented - TotalHandled) AS AbandonedByFunctionelseSUM (TotalHandled - Presented ) AS AbandonedByFunctionJai Krishna |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-01-12 : 05:47:40
|
| use case than if for performance level |
 |
|
|
whitmoj
Yak Posting Veteran
68 Posts |
Posted - 2009-01-12 : 05:59:09
|
| JAII have already tried this and all I get is Incorrect syntax near the keyword 'if'. and Incorrect syntax near 'SUM'.WhitmojIf you are in a hurry you will never get there |
 |
|
|
Jai Krishna
Constraint Violating Yak Guru
333 Posts |
Posted - 2009-01-12 : 06:00:13
|
| if(presented>TotalHandled)BEGINSELECT SUM (Presented - TotalHandled) AS AbandonedByFunctionENDelseBEGINSELECT SUM (TotalHandled - Presented ) AS AbandonedByFunctionENDJai Krishna |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-01-12 : 07:19:27
|
| select case when Presented > TotalHandled then SUM (Presented - TotalHandled) else sum(TotalHandled - Presented) end AS AbandonedByFunctionfrom urtable group by Presented |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-12 : 09:15:13
|
| [code]select SUM (ABS(Presented - TotalHandled)) AS AbandonedByFunctionfrom urtable group by Presented[/code] |
 |
|
|
|
|
|