Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2003
    Posts
    21

    Question Unanswered: Why ROUND doesnt work on aggregated valuse

    Hi all

    Im trying to round aggregated fields, however it seems the
    round command is ignored and i keep getting .000000000001 values.

    Why is the ROUND command ignored in the following statement?

    SELECT
    ROUND (SUM (Purchases) ,2) FROM tbl_Product_Purchases

    What can I try which will work?

    thanks.

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    What kind of field is Purchases? Is it floating point or real? These are approximate values, and are subject to rounding errors.

    Try this and see if it doesn't solve your problem:

    SELECT ROUND (SUM (Cast(Purchases as Decimal(10,2))) ,2) FROM tbl_Product_Purchases

    blindman

  3. #3
    Join Date
    Aug 2003
    Location
    Delft, The Netherlands (EU)
    Posts
    447
    ... or consider to retrieve your value as an integer:

    SELECT FLOOR (SUM (Purchases) * 100) FROM tbl_Product_Purchases
    Make everything as simple as possible, but not simpler! - A. Einstein
    DB Problems? DB Explorer, BTrieve Re-engineering, DB Conversions & ETL? Conversion Tool

  4. #4
    Join Date
    Jul 2003
    Posts
    21

    Smile Problem solved

    Thanks Blindman, it works perfrctly now.

Posting Permissions

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