Coalesce and Conversion

  • Very nice question Tom. Learnt something new today:-)

    ~ Lokesh Vij

    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post -->[/url]

    Follow me @Twitter

  • thanks good and very tough question!

    "The best way to prepare for programming is to write programs, and
    to study great programs that other people have written." – Bill Gates

  • Great question, must say. +1

  • Interesting question, thank you Tom.

    (even kind of knowing the output for each select statement, it tempted me to challenge self and to prove it)

    ww; Raghu
    The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.

  • Thanks for the great question Tom. It really made me think; there were so many choices and it was so early in the morning. I can definitely say I'm awake now. 😀

    Everything is awesome!

  • Great QoTD..


  • john.arnott (1/8/2013)

    How annoying. You made me think! 😉

    I agree this was an excellent question and explanation. I do see that one minor correction could be needed to one example given, however. You say "...for example the numeric value 37.2 can be converted to an int (37)...". Did you actually mean that an INT (@i) could be converted to the higher precedence numeric type, as obviously could be the literal value 37.2? After all, the result of that coalesce is 37.2 and not 37.

    yes, I did. Obviously my check-reading what I had written wasn't up to scratch that day. :blush:

    edit: On second thoughts no; what I really meant was that no conversion was required because the decimal value 37.2 already has the type (decimal) with highest precedence of the three parameters to that coalesce expression.


  • really very tough one...

    You cannot get to the top by sitting on your bottom.

  • I got the result by executing the each statement 🙂

Viewing 9 posts - 16 through 23 (of 23 total)

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