Show the decimal part in query

Last post 06-19-2008 7:58 AM by su.rameshraj. 3 replies.

Sort Posts:

  • Show the decimal part in query

    06-19-2008, 5:58 AM

    Hi,

    In the following query the calculator gives value 3.3  but the query returns 3.0

    I need to get the decimal part also. i.e I need to get 3.3 as answer from the query.

    select cast(66/20 as decimal(6,2)) 

    Need help.

    Thanks
     

    Filed under: , , , ,
  • Re: Show the decimal part in query

    06-19-2008, 6:52 AM
    Answer

    select cast(66 as float)/20 

    or

    cast( ( select cast(66 as float)/20 )  as decimal(6,2))   --(if required to convert into 2 digits)

     

  • Re: Show the decimal part in query

    06-19-2008, 7:07 AM
    Answer
    • Loading...
    • sasi.k
    • Joined on 03-26-2007, 12:27 PM
    • Posts 296

    Hi,

    For displaying single decimal place , try this one

    SELECT CAST( (Select CAST(66 AS float)/20) as decimal(6,1))

    Regards,
    Sasi

    Please remember to click "Mark as Answer" on this post if it helped you.
  • Re: Show the decimal part in query

    06-19-2008, 7:58 AM

    Thanks a lot

    Have a great day 

Page 1 of 1 (4 items)
Microsoft Communities
Page view counter