Query does not display decimal points RRS feed

  • السؤال

  • Hi All,

    I have simple query. When I divide a numer in SQL by another number then it does not display the decimal points.

    Eg: "Select 60/11" gives me answer as "5"

    Eg: "Select cast((60/11) as decimal(5,2))" or "Select CONVERT(decimal(5,2),(60/11))" gives me answer as "5.00"

    But, I want the answer as "5.45" and that also on SQL side, because I don't want to handle this on coding side.

    Please help!!! Thanks in advance...

    19/ذو القعدة/1431 05:48 ص


  • Select


    CAST(60/11.0 AS DECIMAL(18,2))

    Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/
    • تم وضع علامة كإجابة بواسطة Dhaval Tamhane 19/ذو القعدة/1431 07:58 ص
    19/ذو القعدة/1431 07:34 ص
    المجيب على الأسئلة

جميع الردود