Need some help - Float column type, force two decimal numbers

  • Hi,

    I have the following values in a Float column

    266.5

    280.98

    127.558

    How do I set the precision in a SELECT? I need to display two digits after the decimal point. My problem is the first number where I have no idea how to force to have the 0. If I try using ROUND nothing happens.

    Thanks,

    George

  • George

    Have you tried CONVERTing to or CASTing as decimal?

    Really, though, this is a job for the presentation layer, not the database layer. Where are you displaying the results?

    John

  • gpascanu (4/11/2014)


    Hi,

    I have the following values in a Float column

    266.5

    280.98

    127.558

    How do I set the precision in a SELECT? I need to display two digits after the decimal point. My problem is the first number where I have no idea how to force to have the 0. If I try using ROUND nothing happens.

    Thanks,

    George

    I'm not quite sure what you mean there. Where do you want the 0? I read that as you only want to see the digits after the decimal point ie

    0.5

    0.98

    0.56

    I don't think that's right though.


    On two occasions I have been asked, "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" ... I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
    —Charles Babbage, Passages from the Life of a Philosopher

    How to post a question to get the most help http://www.sqlservercentral.com/articles/Best+Practices/61537

  • I am using the values in an SQL Report which I can not modify and I was expecting a number in this format XXXXXXX.XX

    Thanks for the answers, actually converting it to Decimal solved the problem (CONVERT(DECIMAL(10,2), Amount) I wasn't thinking. 🙂

    George

Viewing 4 posts - 1 through 3 (of 3 total)

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