Home » SQL & PL/SQL » SQL & PL/SQL » HELP WITH EASY SELECT DECODE ROUND
HELP WITH EASY SELECT DECODE ROUND [message #425551] |
Fri, 09 October 2009 11:03  |
justin91980
Messages: 3 Registered: October 2009
|
Junior Member |
|
|
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
[Updated on: Fri, 09 October 2009 11:12] Report message to a moderator
|
|
|
Re: HELP WITH EASY SELECT DECODE ROUND [message #425565 is a reply to message #425551] |
Fri, 09 October 2009 12:06   |
justin91980
Messages: 3 Registered: October 2009
|
Junior Member |
|
|
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;
|
|
|
|
|
|
Goto Forum:
Current Time: Mon Feb 17 15:02:44 CST 2025
|