Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: DECODE question
jbatista_at_abcsolutions.org (Josue Batista) writes:
> Given the following two columns:
>
> ACCTD_AMOUNT_DUE_REMAINING NOT NULL NUMBER
> AMOUNT_DUE_REMAINING NOT NULL NUMBER
>
> What does the following statement mean?
>
> sum(decode(NULL,'Y',acctd_amount_due_remaining,amount_due_remaining))
>
I'll go out on a limb....
TO me this looks like a very silly bit of SQL to me.
The decode statement is similar to an if statement and could be translated as
if 1st arg = 2nd arg
return 3rd arg
else
return 4th arg
which in turn translates to
if NULL = 'Y'
return acctd_amount_due_remaining
else
return amount_due_remaining
since NULL never equals anything, this decode will always return amount_due_remaining. So, I tink the whole statement is equal to
sum(amount_due_remaining)
Maybe there is something missing like
sum(decode(nvl(sum_flag_value, 'N'),'Y', acctd_amount_due_remaining, amount_due_remaining));
Tim Received on Tue Nov 12 2002 - 16:39:08 CST