Rounding

  • Hi,

    Small requirement!

    -- Rounding to 1 decimal place

    create table test01

    (id float

    )

    truncate table test01

    insert into test01

    SELECT 21.6216216216216

    UNION ALL

    SELECT 18.3783783783784

    union all

    select 51.0371780739553

    -- i would like to round to 1 ,decimal place

    -- Case : consider 3 rd record

    select ID,

    ROUND(convert(float,id),1)

    from test01

    /* Output

    21.621621621621621.6

    18.378378378378418.4

    51.037178073955351

    */

    /*Required my Output

    21.621621621621621.6

    18.378378378378418.4

    51.037178073955351.0

    */

    Thanks in advance

  • Hi,

    Try using numeric datatype.

    As-

    select ID,

    ROUND(convert(numeric(18,1),id),1)

    from test01

    Good Luck

  • Thanks 🙂

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

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