ROUND ISSUE

  • HI guy need to round the following (PO_LINE.QTY*PO_LINE.PRICE) QTY is float,PRICE  IS MONEY. I am ending up with 447.03030000000004 need to have 447.03.look through examples could find the answers

    THANKS!!!!

     

  • your result is being implicitly converted to a float datatype which gets goofy like this.  You should tell the result to round and put the result into a numeric or money datatype with the desired precision if you do not want to see this.

    See CONVERT and ROUND functions.

  • Tried this and it will work's but only if I run it with out the group by and compute statement CONVERT(NUMERIC(5,2),PO_LINE.QTY*PO_LINE.PRICE) problem is  when I copy this line to the group by list I get the following error, also tried using this as well (PO_LINE.QTY*PO_LINE.PRICE) in the group by but neither works.

    Server: Msg 411, Level 16, State 2, Line 8

    COMPUTE clause #1, aggregate expression #1 is not in the select list.

     

    thanks

  • This one works for me:

    use northwind

    select cast(unitprice * quantity as decimal(8,2)) as price from [order details]

    group by productid,cast(unitprice * quantity as decimal(8,2))

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

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

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