September 1, 2010 at 8:38 pm
Comments posted to this topic are about the item Predict the outcome of the SQL statements
September 1, 2010 at 10:23 pm
I would prefer that you gave a better answer/reason for the result of the first expression being 1 instead of 2. The reason is not simply because of the use of the DECIMAL datatype. It is because no precision and scale was specified. The default precision is 18 and the default scale is 0. This results in rounding to zero decimal places (i.e. it effectively results in an integer). In this situation, the floor function simply returns the value (it doesn't need to do anything since the DECIMAL (18,0) value is the same as the result of the floor function).
September 2, 2010 at 12:11 am
Thanks for explaining it clearly. I had missed this point.
Saurabh Dwivedy
___________________________________________________________
My Blog: http://tinyurl.com/dwivedys
For better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537
September 2, 2010 at 12:24 am
Yes Happycat...Good Explanation.
Select ceiling(Convert(decimal(2,1),1.09)) will give you the result 2.
September 2, 2010 at 1:09 am
Thanks for the better explanation of the Decimal function, as I was very confused about that one statement!
Intersting question though.
September 2, 2010 at 2:29 am
Thanks happycat for the detailed explanation, makes perfect sense now.
_____________________________________________________________________
[font="Comic Sans MS"]"The difficult tasks we do immediately, the impossible takes a little longer"[/font]
September 2, 2010 at 3:53 am
Nice question, but the explanation could be better, as Happycat already demonstrated.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
September 2, 2010 at 6:56 am
Great follow on explanation. Thanks.
September 2, 2010 at 9:05 am
Added a bit to the explanation, as per Happycat59
September 2, 2010 at 10:17 am
Thanks for the question.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
September 2, 2010 at 12:13 pm
Thanks for the question and for Happycat59's further explanation. I learned something new.
Julie
September 7, 2010 at 10:35 am
Nice fun question.
Tom
March 19, 2012 at 10:41 am
Interesting question.
Viewing 13 posts - 1 through 12 (of 12 total)
You must be logged in to reply to this topic. Login to reply