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: HELP! Oracle script for identify identical records

Re: HELP! Oracle script for identify identical records

From: Stefan Oravec <pichtik_at_gmail.com>
Date: Thu, 19 Jul 2007 13:25:43 -0000
Message-ID: <1184851543.918710.215430@m37g2000prh.googlegroups.com>


On Jul 18, 5:41 pm, "ko" <ko..._at_singnet.com.sg> wrote:
> I have a table which consists of n columns. I need to list those identical
> records.
> The coditions for identical records are column A and column B of those
> records must contain the same value and column C must contain 'Y'.
> Can someone enlighten me how to write an Oracle SQL script to accomplish
> this?
>
> Many thanks for your help.

select *
  from t t1
 where c = 'Y'
   and exists (select null

                 from t t2
                where t2.a = t1.a -- same a
                  and t2.b = t1.b -- same b
                  and t2.c = 'Y'
                  and t1.rowid != t2.rowid -- different row
              )

;

or

select *
  from t
 where c = 'Y'
   and (a,b) in (select a,b

                   from t
                  where c = 'Y'
                  group by a,b -- group records with same a,b
                 having count(*) > 1 -- choose groups with more then 1
row
                )

;

S. Received on Thu Jul 19 2007 - 08:25:43 CDT

Original text of this message

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