How can I round the number and remove decimal palces

  • Hi,

    How can I round the number and remove decimal palces in sql server in simple way?

    EX:134.678

    I need result like this 135

  • Is it something you are looking for?

    Declare @int decimal

    Set @int = 123345.524

    Select ROUND(@int,0)

  • kuppurajm (4/27/2011)


    Hi,

    How can I round the number and remove decimal palces in sql server in simple way?

    EX:134.678

    I need result like this 135

    What result do you expect from 134.478?


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • thank you. It's work fine.

    but while I am giving like

    select ROUND(16.8712,0) it gives the result like 17.0000

    It has been resolved by converting as numeric datatype

  • I like the following.

    select floor(convert(decimal(15,8),100.988907))

    , convert(decimal(15,8),100.988907)

    , ceiling(convert(decimal(15,8),100.988907))

  • ROUND returns the same datatype as the value being rounded. So, if you want a different type (like INT) then you need to CAST it.

Viewing 6 posts - 1 through 5 (of 5 total)

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