November 11, 2013 at 11:29 pm
I have a calculated field in my SP. Please help to handle the exception rose if the start date and end date are same and occur a division by zero exception. How to return the value 1 if the start date and end date are same?
SELECT Min(A.EndDate) AS EndDate,
Sum(A.budgetedTotalWorkload)/ (DATEDIFF(day, A.StartDate, A.EndDate)) AS Workload
INTO #TotalWorkload
FROM #Activities2 AS A
GROUP BY A.EndDate,A.StartDate
November 11, 2013 at 11:43 pm
CASE wHEN (DATEDIFF(day, A.StartDate, A.EndDate)) = 0 THEN 1 ELSE Sum(A.budgetedTotalWorkload)/ (DATEDIFF(day, A.StartDate, A.EndDate)) END
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
November 12, 2013 at 6:59 am
Thanks Gila for that post.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply