Re: DECODE
From: The Magnet <art_at_unsu.com>
Date: Fri, 16 Apr 2010 22:33:10 -0700 (PDT)
Message-ID: <38195de7-bedf-4f8a-ad75-60b67d490b98_at_z11g2000yqz.googlegroups.com>
On Apr 16, 5:33 pm, John Hurley <hurleyjo..._at_yahoo.com> wrote:
> On Apr 16, 6:03 pm, The Magnet <a..._at_unsu.com> wrote:
>
> snip
>
> > Can you nest DECODE with different field criteria? Here is our
> > DECODE:
>
> > DECODE(SUM(DECODE(subproduct_id, 238, 1, 0)) OVER (PARTITION BY
> > customer_id),0,'N','Y') ultimate_trader
>
> > Now, with that, if the result is Y, meaning that they DO have this 238
> > product, I want to see if they have a status = 'Active'. So, is there
> > a way to implement yet another level, testing the status = 'Active' if
> > the result of the above statement is 'Y'?
>
> Did you try testing what you wanted to do?
>
> Have you ever heard of inline views?
Date: Fri, 16 Apr 2010 22:33:10 -0700 (PDT)
Message-ID: <38195de7-bedf-4f8a-ad75-60b67d490b98_at_z11g2000yqz.googlegroups.com>
On Apr 16, 5:33 pm, John Hurley <hurleyjo..._at_yahoo.com> wrote:
> On Apr 16, 6:03 pm, The Magnet <a..._at_unsu.com> wrote:
>
> snip
>
> > Can you nest DECODE with different field criteria? Here is our
> > DECODE:
>
> > DECODE(SUM(DECODE(subproduct_id, 238, 1, 0)) OVER (PARTITION BY
> > customer_id),0,'N','Y') ultimate_trader
>
> > Now, with that, if the result is Y, meaning that they DO have this 238
> > product, I want to see if they have a status = 'Active'. So, is there
> > a way to implement yet another level, testing the status = 'Active' if
> > the result of the above statement is 'Y'?
>
> Did you try testing what you wanted to do?
>
> Have you ever heard of inline views?
Been trying things, basically it is something like this:
IF product = 238 THEN
IF status = 'Active' THEN
x = 'Y'
ELSE
x = 'N'
END IF
END IF
I am looking to put that kind of logic into a SELECT statement.
Received on Sat Apr 17 2010 - 00:33:10 CDT