Convert Integer to Decimal

  • I am trying to get my frequency to come out as 1.3, 2.8, 4.4, etc. Basically a decimal output. How would I do this?

    Declare @Month Varchar;

    Select Month, SUM(Month) as MonthlyTotal,(100 * SUM(Month)/260504) As Frequency

    From GetTotalOf1(@Month)

    Group by Month

    MonthMonthlyTotalFrequency

    13583 1

    27318 2

    311688 4

    413524 5

    516665 6

    622572 8

    727167 10

    834720 13

    938016 14

    1034790 13

    1124673 9

    1225788 9

  • Not sure what is in your table valued function but you can do it 2 ways

    Select Month, SUM(Month) as MonthlyTotal,(100 * SUM(convert(decimal(4,1), Month))/260504) As Frequency

    From GetTotalOf1(@Month)

    Group by Month

    OR

    Select Month, SUM(Month) as MonthlyTotal,(100 * SUM((Month* 1.0))/260504) As Frequency

    From GetTotalOf1(@Month)

    Group by Month

  • Thanks Ray M.

    It worked!! That's what I was looking for.

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

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