Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> newbie- decode, case or other SQL in Oracle 9i?

newbie- decode, case or other SQL in Oracle 9i?

From: <bbcrock_at_gmail.com>
Date: 5 Oct 2005 08:47:01 -0700
Message-ID: <1128527221.902188.180140@g14g2000cwa.googlegroups.com>


My customers have a report that uses preliminary and final cost amounts. They requeted a change to the data model so they can track the historic preliminary amount with the final amount. They want to modify the report to read something like:

If finalamount field is 0 then use preliminaryamount field, if finalamount field contains a value, us that. Group the sum of both amounts by type.

I have an existing report that only references finalamount. This is an easy issue, I'm sure, and want to solve it in SQL without running two queries.

Can I use decode or case to do this? I can't make it work. How would you write something like this? I'm attempting something like: select AmountType,
CASE WHEN (finalamount = 0) THEN preliminaryamount ELSE finalamount from BudgetTable

but that's not even close.

I'm going through Ask Tom and metalink, but not getting it.

thanks,

Don Received on Wed Oct 05 2005 - 10:47:01 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US