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
 General SQL Server Forums
 New to SQL Server Programming
 divide by zero error

Author  Topic 

aash
Starting Member

11 Posts

Posted - 2011-03-28 : 15:05:11
This query returns 'divide by zero' error, I dont exactly know about using NULLIF or something like that to avoid rows that has 0 value in it. Any suggestions?

SELECT
t.RDATE,
t.VIER,
t.TDS,
t.TKS,
t.KSDoc,
(t.TKS)/(t.Mins) *60.0 as KSHR,
round(((t.TKS)/(t.Mins) *60.0)/(t.KSDoc), 2, 0) as DPH,
round(" & Norm & "/((t.TKS)/(t.Mins) *60.0)*((t.TKS)/ (t.Mins) *60.0)/(t.KSDoc), 2, 0) as Norm,
round(t.TKS/((t.TKS)/(t.Mins)), 2, 0) as Minutes

From
(SELECT
VDATE as RDATE,
VSON as VIER,
sum(TAIMS) as TDS,
Sum(NOKES) as TKS,
Sum(NOKES) /Sum(TAIMS) as KSDoc,
Sum(ETES - STES) As Mins

FROM WINTPOP

WHERE (VDATE Between '" & Format(DTPicker1.Value, "MM/DD/YYYY") & "' And '" & Format(DTPicker2.Value, "MM/DD/YYYY") & "')Group by VDATE,VSON) t"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-03-28 : 15:15:17
Is this for MS Access?
Go to Top of Page

aash
Starting Member

11 Posts

Posted - 2011-03-28 : 15:21:26
No , with SQL server
Go to Top of Page

aash
Starting Member

11 Posts

Posted - 2011-03-28 : 16:17:19
I got it working just neglecting the row that has 0 value in it. No need for me to use NULLIF as my query simply ignores if the row has a null value in it....
Go to Top of Page
   

- Advertisement -