Round off to the nearest value

  • Hi,

    I'm using this query to round off the numbers and this round off the next value. Now I need to round off to the nearest value means if the value is 45.67 then the value should be 45.

    parsename('$' + convert(varchar,convert(money,round(sum(Column1 * Column2),0)),1),2)

    Really appreciate any suggestions.

  • Cast to int, ie

    SELECT CAST(45.67 as int)

    will give you 45

    Far away is close at hand in the images of elsewhere.
    Anon.

  • Have you tried the FLOOR function?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Or you can use the truncate option of ROUND()

    SELECT ROUND(45.67, 0, 1)

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

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

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