Divide by Zero - bit lost

  • Hi Guys, Sorry but i am pretty stupidly new at SQL and need a bit of help, i've had a look through previous posts but cant seem to find what im looking for. i'm trying to do a calculation to get a total score (obvious eh), but i keep gettin a divide by zero error, which from what little i know means i need to use a CASE WHEN in the code. However being so new to SQL. I havent a clue! Its a lenghty bit of code, any pointers would be great!! the code is "(SUM(dbo.t_DirectHighLevelSummary.FlashConn) + SUM(dbo.t_DirectHighLevelSummary.TalkConnQWBR) - SUM(dbo.t_DirectHighLevelSummary.SimplicityConn1)) - SUM(dbo.t_DirectHighLevelSummary.TalkMobileConn) / SUM(dbo.t_DirectHighLevelSummary.TGM)"

    Nice 1

  • Hi,

    Instead your query, try this:

    (SUM(dbo.t_DirectHighLevelSummary.FlashConn) +

    SUM(dbo.t_DirectHighLevelSummary.TalkConnQWBR) -

    SUM(dbo.t_DirectHighLevelSummary.SimplicityConn1))

    - SUM(dbo.t_DirectHighLevelSummary.TalkMobileConn) / CASE WHEN SUM(dbo.t_DirectHighLevelSummary.TGM)=0 THEN 1 ELSE SUM(dbo.t_DirectHighLevelSummary.TGM) END

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply