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

Home -> Community -> Usenet -> c.d.o.server -> Re: oracle SQL question..

Re: oracle SQL question..

From: Chrysalis <cellis_at_iol.ie>
Date: 1998/05/28
Message-ID: <cellis-ya02408000R2805981313460001@news.clubi.ie>#1/1

In article <6ki3m2$7sd$2_at_engnews2.Eng.Sun.COM>, gosar_at_EBB.Eng.Sun.COM wrote:

> Hi,
>
> I have table ....
>
> KC MKT PLT QTY
> ---------- ---------- --- ----------
> 100 M1 P1 1
> 100 M1 P1 2
> 100 M1 P1 3
> 200 M2 P1 1
> 300 M3 P3 1
> 200 M2 P2 1
> 100 M1 P2 1
>
> I want to select everything which is in PLT='P1' and
> only those records from other PLT's which have different
> combination of "KC, MKT and QTY fields"....
>
> snip

select ...
from your_table
where plt = 'P1'
UNION
select ...
from your_table T1
where plt <> 'P1'
and not exists
(select null from your_table T2
where T2.plt = 'P1'
 and (T2.kc,T2.mkt,T2.qty) in ((T1.kc,T1.mkt,T1.qty)));

HTH

-- 
Chrysalis
Received on Thu May 28 1998 - 00:00:00 CDT

Original text of this message

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