Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004

    Unanswered: convert value to 2 digits after decimal

    I'm having a query as follows:
    SELECT 41.78 * 0.01 * 17 + 41.78 AS new_price

    it returns 48.8826, but how do I set it up that it would round it nicely to two digits? as of 48.88


  2. #2
    Join Date
    Sep 2002
    Provided Answers: 1

    Re: convert value to 2 digits after decimal

    In Oracle you would use ROUND(value,2).

  3. #3
    Join Date
    Feb 2004
    In front of the computer
    Provided Answers: 54
    Just an observation, but rounding is really a client-side issue. In all but a few cases, it should really be handled by the client instead of the server.

    Most servers will accept the:

    SELECT Round(41.78 * 0.01 * 17 + 41.78, 2) AS new_price

    syntax, but you still should do the rounding at the client if you can. Someday you might decide that you want the "full value", or maybe you'll need to round at a different precision than 2 for some clients... Not that I've ever had that happen, I just read about it in a book once.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts