Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 12890

Rectifying Divide By 0 query

$
0
0

The following is part of my SELECT clause that is giving me divide by 0 error:

[TotalHours]/SUM(CASE WHEN J.Description = 'C' THEN 1 ELSE 0 END) AS 'MTBF'

Im trying to rectify the divide by 0 like this:

[TotalHours]/CASE WHEN SUM(CASE WHEN J.Description = 'C' THEN 1 ELSE 0 END) = 0 THEN 1 ELSE SUM(CASE WHEN J.Description = 'C' THEN 1 ELSE 0 END) AS 'MTBF'

However the above statement is giving me red squigglies under 'AS'

May somebody please offer a suggestion on how to rectify this?

Thanks.



Viewing all articles
Browse latest Browse all 12890

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>