Annotations for "ROUND (Transact-SQL)" topic.Wed, 30 Jul 2014 05:25:40 Z
http://msdn.microsoft.com/en-us/library/ms175003(v=sql.105).aspx#CommunityContent
Darren WoodfordTruncate might require CASTIf the source data columns contain decimal places then you might need to CAST to a data type without decimal places. So
CAST(ROUND(SUM(Price),0,1) AS Decimal(22,0))Fri, 06 Jul 2012 16:16:25 -0700
http://msdn.microsoft.com/en-us/library/ms175003(v=sql.105).aspx#CommunityContent
Darren WoodfordTruncate doesn't work with decimal columnsThe truncate argument doesn't work with decimal columns. I have a column named price which is specified as decimal(22, 7). The following querySELECT ROUND(SUM(Price),0,1)AS SumNetPrice FROM Transactions
gives the resultL 32243.0000000 whereas it should give 32243.Fri, 06 Jul 2012 15:47:07 -0700
http://msdn.microsoft.com/en-us/library/ms175003(v=sql.105).aspx#CommunityContent
Ganesh Shankar DixitRound FunctionDECLARE @NOM INT=5, @DENOM INT=3SELECT ROUND(@NOM/CONVERT(FLOAT,@DENOM),2)Sat, 25 Feb 2012 15:22:42 -0800
http://msdn.microsoft.com/en-us/library/ms175003(v=sql.105).aspx#CommunityContent
meroondown roundingHi, I have a doubt with the down rounding-> Floor function is used for this.My doubt is if I use floor for this value 748.58956 I get the output as 748. What I expect is this should be rounded to two decimal places like this 748.59.Do anyone have idea on this? Thu, 12 Jan 2012 07:42:55 -0800
http://msdn.microsoft.com/en-us/library/ms175003(v=sql.105).aspx#CommunityContent
TechVsLife2unbiased rounding (round to even) missingOne major flaw: the t-sql ROUND function does not have an unbiased rounding option (bankers' round or "round to even"). That is the IEEE 754 standard, and the default round option in .net and vb/vba, and even mdx. the t-sql function uses the common method, producing an upward (positive) bias. (bankers is unbiased if there is no skew for odd or even numbers).Tue, 26 Jul 2011 07:45:34 -0700
http://msdn.microsoft.com/en-us/library/ms175003(v=sql.105).aspx#CommunityContent
MicnickRound to minus valueI like round a value for example 7505.45 to 7505.00 but the Round function result is 7506
Why?Thu, 28 Apr 2011 15:20:16 -0700
http://msdn.microsoft.com/en-us/library/ms175003(v=sql.105).aspx#CommunityContent
DWalkerIt does NOT always return a valueThe Remark that "ROUND always returns a value" is not correct -- it can result in an arithmetic overflow. Also, Round presumably can return Null, which may not be "a value" depending on your definition. That remark in the description is not very useful.The second Remark "ROUND returns a rounded numeric_expression, regardless of data type, when length is a negative number" is not correct either, as the arithmetic overflow example shows.Mon, 18 Apr 2011 19:26:24 -0700
http://msdn.microsoft.com/en-us/library/ms175003(v=sql.105).aspx#CommunityContent
LumbagoSevere limitation - arithmetic overflowThe ROUND function throws an arithmetic overflow error if the result of the rounding operation causes the precision to change. Although it makes sense that the same data type is returned from the function as is being passed in, it is highly impractical in some situations: SELECT ROUND(9.6, 0)SELECT ROUND(0.96, 1)SELECT ROUND(0.9996, 3)All of the above will throw the following error:
Arithmetic overflow error converting expression to data type numeric.Tue, 15 Mar 2011 12:36:28 -0700
http://msdn.microsoft.com/en-us/library/ms175003(v=sql.105).aspx#CommunityContent
Hugo KornelisCorrectionThe community content added by Venkatesan Prabu Jayakantham is not correct. The query he posts does not round up (ceil velue); it rounds to the nearest multiple of 10 (because the -1 specifies to round to the -1st position to the right off the decimal place, or the 1st position to the left of it).Try SELECT ROUND(14.46123,-1) - you'll see that the result is 10 (rounded down to the nearest multiple of 10), not 15 (what the result of CEILING(14.46123) would be)Sun, 12 Sep 2010 12:33:27 -0700
http://msdn.microsoft.com/en-us/library/ms175003(v=sql.105).aspx#CommunityContent
Venkatesan Prabu JayakanthamRounding to the upper value for the precisionRounding to the ceil value can be achieved from the below query.
SELECT ROUND(19.46123,-1 ) as total
I am really impressed with this function and I have written an article on this.
http://venkattechnicalblog.blogspot.com/2010/08/round-function-in-sql-server.html
Cheers,
Venkatesan Prabu .JSat, 04 Sep 2010 11:32:07 -0700