Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Rounding in SQL Server


Rounding in SQL Server

Author
Message
SandyC3339
SandyC3339
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 1
I am trying to sum two numbers and round the result but SQL Server does not appear to like the function of ROUND. Can someone tell me the syntax for this function.

Thanks



SJTerrill
SJTerrill
SSC-Addicted
SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)SSC-Addicted (486 reputation)

Group: General Forum Members
Points: 486 Visits: 728
Try SELECT Round(12345.6789,2). This should return 12345.6800. Note that ROUND doesn't actually modify the precision of the result. If the second argument is negative, it is interpreted as a number of digits to the left of the decimal point to round to... Thus SELECT Round(12345.6789,-1) will return 12350.0000 and SELECT Round(12345.6789,0) will return 12346.0000. If you need to truncate precision to an integer, try SELECT Floor(Round(12345.6789,0)). Search Books Online for Round for more info.

HTH,

-SJTerrill



Edited by - TheWildHun on 11/07/2003 1:03:01 PM



Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search