﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by Pradyothana Shastry  / Round / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sun, 19 May 2013 06:08:33 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Round</title><link>http://www.sqlservercentral.com/Forums/Topic987876-2603-1.aspx</link><description>Thanks for the question.I hardly use math functions at work, so its sometimes a shock that these simple functions can be so tricky..... A misunderstood (or missing) parameter would mean that the calculations would be inaccurate:w00t:</description><pubDate>Tue, 22 Nov 2011 01:36:10 GMT</pubDate><dc:creator>terrykzncs</dc:creator></item><item><title>RE: Round</title><link>http://www.sqlservercentral.com/Forums/Topic987876-2603-1.aspx</link><description>Very Nicely Explained!!Thanks.</description><pubDate>Mon, 20 Sep 2010 06:41:59 GMT</pubDate><dc:creator>niki-659689</dc:creator></item><item><title>RE: Round</title><link>http://www.sqlservercentral.com/Forums/Topic987876-2603-1.aspx</link><description>[quote][b]honza.mf (9/17/2010)[/b][hr][quote][b]tommyh (9/16/2010)[/b][hr]Nice question. Though the explanation isnt entirely accurate. Its not rounded, its truncated.  If the question had been, lets say [code="sql"]declare @r decimal(5,2)set @r= round(5/[b]3.2[/b],1,3)select @r[/code]Then we would get 1.5 wheras a round would have given us 1.6 (change last parameter in Round to 0... or remove it all together).[/quote]Right, the 3rd parameter of round is the most important one. It's value 3 is not typical but greater than zero.[/quote]Just to be picky, it's not because the third parameter is greater than zero, but because it is not equal to zero.  Here's the entry in BOL for SQL 2005: [quote]Syntax ROUND ( numeric_expression , length [ ,function ] ) Argumentsnumeric_expressionIs an expression of the exact numeric or approximate numeric data type category, except for the bit data type.length Is the precision to which numeric_expression is to be rounded. length must be tinyint, smallint, or int. When length is a positive number, numeric_expression is rounded to the number of decimal positions specified by length. When length is a negative number, numeric_expression is rounded on the left side of the decimal point, as specified by length.function Is the type of operation to perform. function must be tinyint, smallint, or int. When function is omitted or has a value of 0 (default), numeric_expression is rounded. When a value other than 0 is specified, numeric_expression is truncated.[/quote]</description><pubDate>Sun, 19 Sep 2010 19:41:59 GMT</pubDate><dc:creator>john.arnott</dc:creator></item><item><title>RE: Round</title><link>http://www.sqlservercentral.com/Forums/Topic987876-2603-1.aspx</link><description>The hardest part of the question was figuring out what is the result of 5/3.1IMHO the point of the question would make more sense if it had been changed to 5/3.0 as the result of the function would actually be affected by the third parameter of the ROUND function unlike in this question.To illustrate:[code="sql"]select     Example = 'Your example'    ,input_data = '5/3.1'    ,Truncation = ROUND(1.612903, 1, 1) -- 1.600000     ,Rounding  = ROUND(1.612903, 1, 0) -- 1.600000 union allselect    'Better example'    ,'5/3.0'    ,ROUND(1.666666,1,1) -- 1.600000     ,ROUND(1.666666,1,0) -- 1.700000[/code][code="plain"]Example        input_data Truncation   Rounding-------------- ---------- ------------ ----------Your example   5/3.1      1.600000     1.600000Better example 5/3.0      1.600000     1.700000[/code]Regards,Hrvoje Piasevoli</description><pubDate>Sat, 18 Sep 2010 18:15:14 GMT</pubDate><dc:creator>hrvoje.piasevoli</dc:creator></item><item><title>RE: Round</title><link>http://www.sqlservercentral.com/Forums/Topic987876-2603-1.aspx</link><description>[quote][b]cengland0 (9/17/2010)[/b][hr]...  I've been bitten by so many QOTDs with an obscure typo or something else tricky.[/quote]I like composing questions that are on the tricky side.  Must be because of all my bad experiences with certification exams.If it's of any consolation, the editors here do have a limit to what they will tolerate for trick questions.  I submitted one a few months ago that never got published.I get it.  The QOTDs are more about the learning experience than the certification experience.I'm working on one now that's a little more tame... :-)</description><pubDate>Fri, 17 Sep 2010 07:29:22 GMT</pubDate><dc:creator>Dave62</dc:creator></item><item><title>RE: Round</title><link>http://www.sqlservercentral.com/Forums/Topic987876-2603-1.aspx</link><description>Good question.  Round is a function with a few gotchas that it is important to know about and understand.  Thanks.</description><pubDate>Fri, 17 Sep 2010 07:17:35 GMT</pubDate><dc:creator>Daniel Bowlin</dc:creator></item><item><title>RE: Round</title><link>http://www.sqlservercentral.com/Forums/Topic987876-2603-1.aspx</link><description>I got it right but hesitated to click the submit button.  It was too easy and I was looking for the tricky part of the question.  I've been bitten by so many QOTDs with an obscure typo or something else tricky.</description><pubDate>Fri, 17 Sep 2010 03:57:47 GMT</pubDate><dc:creator>cengland0</dc:creator></item><item><title>RE: Round</title><link>http://www.sqlservercentral.com/Forums/Topic987876-2603-1.aspx</link><description>Good question, but a real easy one since all the rounding questions of Hugo Kornelis. :-)It would've been more a challenge if you used 3.2 or 3.0, as someone already suggested in this thread.</description><pubDate>Fri, 17 Sep 2010 02:54:35 GMT</pubDate><dc:creator>Koen Verbeeck</dc:creator></item><item><title>RE: Round</title><link>http://www.sqlservercentral.com/Forums/Topic987876-2603-1.aspx</link><description>[quote][b]tommyh (9/16/2010)[/b][hr]Nice question. Though the explanation isnt entirely accurate. Its not rounded, its truncated.  If the question had been, lets say [code="sql"]declare @r decimal(5,2)set @r= round(5/[b]3.2[/b],1,3)select @r[/code]Then we would get 1.5 wheras a round would have given us 1.6 (change last parameter in Round to 0... or remove it all together).[/quote]Right, the 3rd parameter of round is the most important one. It's value 3 is not typical but greater than zero.</description><pubDate>Fri, 17 Sep 2010 02:14:41 GMT</pubDate><dc:creator>honza.mf</dc:creator></item><item><title>RE: Round</title><link>http://www.sqlservercentral.com/Forums/Topic987876-2603-1.aspx</link><description>thanks for the question</description><pubDate>Thu, 16 Sep 2010 23:57:16 GMT</pubDate><dc:creator>SQLRNNR</dc:creator></item><item><title>RE: Round</title><link>http://www.sqlservercentral.com/Forums/Topic987876-2603-1.aspx</link><description>Nice question. Though the explanation isnt entirely accurate. Its not rounded, its truncated.  If the question had been, lets say [code="sql"]declare @r decimal(5,2)set @r= round(5/[b]3.2[/b],1,3)select @r[/code]Then we would get 1.5 wheras a round would have given us 1.6 (change last parameter in Round to 0... or remove it all together).</description><pubDate>Thu, 16 Sep 2010 23:25:25 GMT</pubDate><dc:creator>tommyh</dc:creator></item><item><title>Round</title><link>http://www.sqlservercentral.com/Forums/Topic987876-2603-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/questions/T-SQL/71030/"&gt;Round&lt;/A&gt;[/B]</description><pubDate>Thu, 16 Sep 2010 22:15:58 GMT</pubDate><dc:creator>Pradyothana Shastry</dc:creator></item></channel></rss>