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 |
|
jamie
Aged Yak Warrior
542 Posts |
Posted - 2007-11-06 : 08:10:54
|
| hi,I keep getting a divide by zero error on the following code. :CASE WHEN SUM(l.[1]) = 0 THEN 0 ELSE SUM((b.avgCost * forms.[1])/ l.[1]) END AS [1],How can I get this to work correctly ?thank you for you help.jame |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-11-06 : 08:13:46
|
[code]SUM(CASE WHEN l.[1] = 0 THEN 0 ELSE b.avgCost * forms.[1] / l.[1]END)[/code] E 12°55'05.25"N 56°04'39.16" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-11-06 : 08:27:51
|
| Did you name your column as 1?Make sure you follow good naming conventionMadhivananFailing to plan is Planning to fail |
 |
|
|
jamie
Aged Yak Warrior
542 Posts |
Posted - 2007-11-06 : 09:14:14
|
| hi, [1] was just for testing.Thank you , this works perfectly now !.need to remember to SUM the whole case statement. |
 |
|
|
|
|
|