How do I set variable type for inline calculations?

  • In my Select statement I am trying to calculate a percentage by dividing IntA / IntB * 100 which is of course giving me the wrong answer because the result of IntA / IntB is being calculated as an integer instead of a float. Is there a way to cast them inline to a float or specify that the result needs to be a float? Thanks.

  • Nevermind....strangely enough if I look in the SQL Server books online there it is.....

  • try this: select cast(IntA, float) / cast(IntB, float) * 100



    Bye
    Gabor

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

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