SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast alvin101's Avatar
    Join Date
    Sep 2010
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to use ROUND () in a statment

    I have a statement (below) that gives me a column (price) that shows decimal place of .... I would like to round the result to 2 decimal place. But I can not seem to get it to work. Tried everthing I could find about the ROUND () function.

    What is the best way to get this result?

    Where in this statement would I put ROUND (,2)?

    Code:
    SELECT	inventory.sku
    ,    	inventory.description_short
    ,    	inventory.full_price * .12 + inventory.full_price * 7.69 AS 'price' 
    
    FROM   inventory 
     JOIN inventory_history
        ON inventory.sku = inventory_history.sku
    WHERE inventory_history.store_id = 4
    ORDER BY inventory.sku ASC

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    72 Post(s)
    Tagged
    0 Thread(s)
    that's a very odd select math you're doing there, but

    ROUND(inventory.full_price * .12 + inventory.full_price * 7.69,2) AS 'price'

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,270
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    ROUND(inventory.full_price * 7.81 , 2) AS price

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  4. #4
    Non-Member
    Join Date
    Apr 2004
    Location
    Miami, FL, USA
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What's with the round-about answers...?

  5. #5
    SitePoint Enthusiast alvin101's Avatar
    Join Date
    Sep 2010
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Rudy

    You just hit on something, .12 being tax, and 7.69 being exchange rate. In the end I will need to go to a different table to get them...

    Thanks

    AM


Bookmarks

Posting Permissions

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