Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Can u help to build a Query.....
krisworld wrote:
...
> F1 F2 F3 F4 F5
> -------------------------------
> a b c d 0 (Record 1)
> a b c d 1 (Record 2)
> m n o p 0
> m n o p 1
>
> I require to have a query which shall check the first field and last
> field for comparison
> that is
> if F1 of Record 1 = F1 of Record 2 and F5 of Record 1 =0 and F5 of
> Record 2=1
> then should compare rest of the fields i.e F2 F3 F4
> such as..
> IF F2 of Record 1 <> F2 of Record 2 or F3 of Record 1 <> F3 of Record 2
> or F3 of Record 1 <> F3 of Record 2
>
> the query should pass me the whole field i.e F1 F2 F3 F4 F5
> In other words fetch only records which has a difference.
maybe this:
SELECT a1.*
FROM atable a1, atable a2
WHERE a1.f1 = a2.f1 AND a1.f5 = 0 AND a2.f5 = 1 AND ( a1.f2 <> a2.f2 OR a1.f3 <> a2.f3 OR a1.f4 <> a2.f4);
Cheers
Chris
Received on Fri Jul 14 2006 - 13:51:17 CDT