Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Rounding in SQL Server Expand / Collapse
Author
Message
Posted Friday, November 07, 2003 11:47 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, February 07, 2005 4:35 PM
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




Post #18029
Posted Friday, November 07, 2003 1:00 PM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Wednesday, March 05, 2014 10:14 AM
Points: 477, Visits: 727
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



Post #86399
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse