Decimal point

  • I like to display one decimal point with the result division.

    For example, 7/12 = 58.3%

    How to use dec function?

  • Try this:

    DECLARE @a DECIMAL(5,0)

    DECLARE @b-2 DECIMAL(5,0)

    DECLARE @P DECIMAL(3,0)

    DECLARE @Ans DECIMAL(5,1)

    SET @a = 7.

    SET @b-2 = 12.

    SET @P = 100.

    SELECT ROUND((@A/@B) * @P,1)

    --If you just wish to display the resutl:

    --that is NO further mathametical work

    SELECT SUBSTRING(CAST(ROUND((@A/@B) * @P,1) AS VARCHAR(10)),1,CHARINDEX('.',ROUND((@A/@B) * @P,1),1)+1)+ '%'

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

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

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