Results 1 to 3 of 3

Thread: Format number

  1. #1
    Join Date
    Jan 2004
    Posts
    164

    Unanswered: Format number

    I am doing some simple arithmatic for a query that I am working on. What I have below describes the arithmatic that is taking place withing a portion of the query:

    select(o.sales_val/o.qty_sales) as 'Unit_Price', (o.acctng_cost_val/o.qty_sales) as 'Unit_Cost'
    from opcsahf as o
    go

    The division is correct. My only issue is that the results for 'Unit Price' or 'Unit Cost' may be formatted like example: 4.25000000.


    How can I have my nubers show up with only to 2 decimal places instead of all the zeros at teh end?

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    It really is a presentation layer issue..

    What are the datatypes of the columns

    Did you just try CONVERT(decimal(15,2),.....
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Jan 2004
    Posts
    164
    Brett,

    I went ahead and tryed the convert(decimal(15,2) and everything worked fine. This was the results for the statement:

    select convert(decimal (15,2),o.sales_val/ convert(decimal (15,2),o.qty_sales)) as 'Unit_Price', convert(decimal (15,2),o.acctng_cost_val/ convert(decimal (15,2),o.qty_sales)) as 'Unit_Cost'
    from opcsahf as o
    go

    Thanks alot Brett. It did the trick.


    Originally posted by Brett Kaiser
    It really is a presentation layer issue..

    What are the datatypes of the columns

    Did you just try CONVERT(decimal(15,2),.....

Posting Permissions

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