Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2003
    Posts
    16

    Question Unanswered: How to format numbers in a query

    Hey - I have a quick question and know that it is probably pretty simple, but I am stumped. I have a query where I need to make a colum a number that looks like a percent with 2 significant digits:

    i.e.,
    SELECT tblNumericCovert.number1, tblNumericCovert.number2, [number1]/[number2] AS testDiv
    FROM tblNumericCovert

    where testDiv needs to spit out results like this ###.##

    I am totally lost, if anyone can help, I would appreciate it.

  2. #2
    Join Date
    Sep 2003
    Location
    The extremely Royal borough of Kensington, London
    Posts
    778
    select to_char(number1/number2, '99.99') As testDiv from table;
    Bessie Braddock: Winston, you are drunk!
    Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

  3. #3
    Join Date
    Oct 2003
    Posts
    16
    Originally posted by r123456
    select to_char(number1/number2, '99.99') As testDiv from table;
    When I do this, I get the error message that "to_char is not a vaild function name'

  4. #4
    Join Date
    Jan 2004
    Posts
    3
    What db are you using? to_char works for Oracle, but not SQL server.

    Try:

    select convert(money, (number1/number2)) As testDiv from table

Posting Permissions

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