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 -> Re: sql query wanted

Re: sql query wanted

From: damorgan <dan.morgan_at_ci.seattle.wa.us>
Date: Fri, 22 Feb 2002 17:25:28 GMT
Message-ID: <3C767F1F.46A5AD97@ci.seattle.wa.us>


SELECT DECODE(value_in,

                                'a', 1,
                                'b', 2
                                etc.

RTM. It is all there.

But I am a bit concerned about this part of your request: "if I have a and b it should return 3 and 6"

You will have a very difficult time returning two values from one condition.

Daniel Morgan

Christian Mallwitz wrote:

> damorgan wrote:
> >
> > Look at DECODE.
>
> what should I where decode? in the mean time I was trying to see if
> hierarchical queries would be helpful without results yet :-(
> christian
>
> > > create table foobar (id varchar(10), sku varchar(10));
> > >
> > > insert into foobar values ('1', 'a');
> > > insert into foobar values ('2', 'b');
> > > insert into foobar values ('3', 'a');
> > > insert into foobar values ('3', 'b');
> > > insert into foobar values ('4', 'c');
> > > insert into foobar values ('5', 'a');
> > > insert into foobar values ('5', 'c');
> > > insert into foobar values ('6', 'a');
> > > insert into foobar values ('6', 'b');
> > > insert into foobar values ('7', 'a');
> > > insert into foobar values ('7', 'b');
> > > insert into foobar values ('7', 'c');
> > >
> > > Now I have to query based on sku: I need all id's where there are row's
> > > for that id with exactly the sku's provided.
> > >
> > > Example:
> > > if I have a it should return 1
> > > if I have b it should return 2
> > > if I have c it should return 4
> > > if I have a and b it should return 3 and 6
> > > if I have a and c it should return 5
> > > if I have a, b and c it should return 7
Received on Fri Feb 22 2002 - 11:25:28 CST

Original text of this message

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