1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Help with Select Decode Round

Discussion in 'SQL PL/SQL' started by justin91980, Oct 9, 2009.

  1. justin91980

    justin91980 Active Member

    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    55
    Hi, If anyone could help me with this. I need to round all these numbers in the DECODE but without repeating ROUND.
    This way works:

    SELECT title "Title", category "Category",retail "Current Price",
    DECODE(category,
    'COMPUTER',(ROUND(retail * 1.1,2)),
    'FITNESS', (ROUND(retail * 1.15,2)),
    'SELF HELP', (ROUND(retail * 1.25,2)),
    (ROUND(retail * 1.03,2)))"Revised Price"
    FROM books
    ORDER BY category, title;

    But I need something more like this:

    SELECT title "Title", category "Category",retail "Current Price",
    DECODE (ROUND((category,
    'COMPUTER',retail * 1.1,
    'FITNESS', retail * 1.15,
    'SELF HELP', retail * 1.25,
    retail * 1.03)"Revised Price"),2)
    FROM books
    ORDER BY category, title;

    so that ROUND is not repeated more than once..they all need to be rounded to two decimal places.
    any help would be great. Thanks
     
  2. justin91980

    justin91980 Active Member

    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    55
    Ok, someone helped me figure it out

    SELECT title "Title", category "Category",retail "Current Price",
    ROUND(DECODE(category, 'COMPUTER',retail * 1.1,
    'FITNESS', retail * 1.15,
    'SELF HELP', retail * 1.25,
    retail * 1.03),2) "Revised Price"
    FROM books
    ORDER BY category, title;