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: Help required to find mistached records from two tables...

Re: Help required to find mistached records from two tables...

From: Mark D Powell <Mark.Powell_at_eds.com>
Date: Thu, 06 Sep 2007 14:09:50 -0700
Message-ID: <1189112990.569946.132580@d55g2000hsg.googlegroups.com>


On Sep 6, 1:26 pm, Nick <nachiket.shirwal..._at_gmail.com> wrote:
> Hi,
>
> I have two tables Trade table and Cons table. Records are inserted in
> both the tables independent of each other. There are fields like
> Exc_Ref, Qty, Date in both the tables.
>
> I need to write a query which should give me records :
>
> 1. Where there is missing Exc_Ref value in either of the table. i.e.
> If Trade table has a Exc_Ref value but missing in Cons table then that
> record should be displayed. Similarly if Cons has a Exc_Ref value
> which is not found in Trade table then that too should be displayed.
>
> 2. In case where both the tables have matching Exc_Ref data then it
> should display the record only when the remaining column does not
> match like Qty or Date.
>
> Please help me to resolve this complicated query.
>
> Thanks
> Nick

Look at the minus statement
select * from A
minus
select * from B

will give you all rows in table A not in table B

I would think you could solve this problem by writing a select for each conditon and then UNIONing or perhaps joining the results together.

HTH -- Mark D Powell -- Received on Thu Sep 06 2007 - 16:09:50 CDT

Original text of this message

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