Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Handling the exception Expand / Collapse
Author
Message
Posted Monday, November 11, 2013 11:29 PM


SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Today @ 4:46 AM
Points: 606, Visits: 1,129
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

Post #1513337
Posted Monday, November 11, 2013 11:43 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 6:30 AM
Points: 40,184, Visits: 36,591
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 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1513339
Posted Tuesday, November 12, 2013 6:59 AM


SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Today @ 4:46 AM
Points: 606, Visits: 1,129
Thanks Gila for that post.
Post #1513445
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse