Integer Division to get Percentage

  • I am trying to get percentages. I realize that I am doing integer division and the result will be an integer. I have tried to cast the numerator and the denominator and the entire result. I either get 0.000000 or 1.000000

    Calculation1: sum(a) / (sum a + b) as Percentage (statement without cast/convert).

    Calculation1: sum(b) / (sum a + b) as Percentage (statement without cast/convert).

    I am doing this twice and the percentages will be 99.999365% and 0.000635%.

    Any ideas?

    Thanks.

  • Try making it "sum(a*1.0)" in the numerator. See what that gives you.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • I figured it out; it was a group by with the combination of Case..sum instead of sum(Case).

    Thanks.

  • can you post the entire code.

Viewing 4 posts - 1 through 3 (of 3 total)

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