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 |
mmccardle
Starting Member
43 Posts |
Posted - 2010-06-30 : 15:32:06
|
I'm building a stored procedure for a report and I'm getting a division by zero error. There is only one division problem in the SP:ROUND(CASE WHEN onhand > 0 OR (onhand - threesixtyfivedaysupply + threesixtyfivedayusage) > 0 --BEGINNING BALANCETHEN threesixtyfivedayusage/(((onhand)+(onhand - threesixtyfivedaysupply + threesixtyfivedayusage))/2) ELSE 0 END,2) AS '12monthturns'I thought I had solved the division by zero error with the CASE statement but that apparently is not working. |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-06-30 : 16:14:48
|
onhand + onhand? N 56°04'39.26"E 12°55'05.63" |
 |
|
mmccardle
Starting Member
43 Posts |
Posted - 2010-06-30 : 16:17:49
|
Its a report to find inventory turns, which is calculated by "usage/(ending balance + beginning balance)/2" |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-06-30 : 16:42:30
|
THEN threesixtyfivedayusage/(((onhand)+(onhand - threesixtyfivedaysupply + threesixtyfivedayusage))/2) N 56°04'39.26"E 12°55'05.63" |
 |
|
mmccardle
Starting Member
43 Posts |
Posted - 2010-06-30 : 16:46:28
|
nvm, one value was -5 and the other was 5, thus creating a 0/2 and thus a x/0 error. |
 |
|
|
|
|