If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Please help!

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-27-03, 14:14
RunawayTrain RunawayTrain is offline
Registered User
 
Join Date: Oct 2003
Posts: 1
Exclamation Please help!

Okay, I'm working on a small retail book store database and I need to view some revised prices. I THINK I should be using the DECODE function as shown below in my desperate attempt to complete this task. If not, a little push in the right direction would be MUCH appreciated!

SELECT title, category, retail "current retail price"
FROM books
DECODE(category, "computer", retail*.90,
"fitness", retail*.85,
"self help", retail*.75,
retail*.97) "revised retail price";

I get an error everytime! I even tried having "FROM books" at the end.. that didn't work either! I'm so confused! PLEASE give me a hint as to how I can correct this...

I need to take the current retail price (retail) and according to the books category, issue a discount. I need to display the book title (title), the book's category (category), current retail price (retail) and revised retail price. Category discounts: computer = 10%, fitness = 15%, self help = 25%, and all others = 3%.

Please help me!

_runaway!
oOoo
.o
Oo
o.oO
___C||_
c|_O__ O| .oO(CHOO! CHOO!)
Reply With Quote
  #2 (permalink)  
Old 10-27-03, 14:27
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,455
Exclamation

You need to re-order your SQL like this:

Code:

SELECT title, category, retail "current retail price",
            DECODE(category, "computer", retail*.90,
                       "fitness", retail*.85,
                       "self help", retail*.75,
                        retail*.97) "revised retail price"
FROM books;
__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On