# Predict the outcome of the SQL statements

• Comments posted to this topic are about the item Predict the outcome of the SQL statements

• 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).

• 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

Be Happy!
• Yes Happycat...Good Explanation.

Select ceiling(Convert(decimal(2,1),1.09)) will give you the result 2.

[font="Verdana"]Regards,
Rals
[/font].
• Thanks for the better explanation of the Decimal function, as I was very confused about that one statement!

Intersting question though.

• 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]

• 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

• Great follow on explanation. Thanks.

• Added a bit to the explanation, as per Happycat59

• 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

• Thanks for the question and for Happycat59's further explanation. I learned something new.

Julie

• Nice fun question.

Tom

• Interesting question.

Viewing 13 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic. Login to reply