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: A simple sql*plus question

Re: A simple sql*plus question

From: Bob Johnson <no-email_at_links.into.here>
Date: 1997/02/07
Message-ID: <01bc14b9$8428c160$b92e64a1@azkrdw00173.krd.az.bp.com>#1/1

G'day

You can easily find out which pairs of column values are duplicated with a query such as:-

SELECT a,b
FROM tablename
HAVING count(*) > 1
GROUP BY a,b;

if you want to know how many times the pairs are duplicated just

SELECT a,b,count(*)
FROM .... If you want to select the rows that contain duplicates, try a query such as

SELECT a,b
FROM tablename
WHERE c1||c2 in (

                           SELECT c1||c2
                            FROM   tablename
                            HAVING count(*) > 1
                            GROUP  by c1||c2
                            );

Hope this helps.
Bob Johnson
BP Oil Kwinana
West Australia

Brian Cameron <bcamero5_at_metz.une.edu.au> wrote in article <5de5i8$91s$1_at_gruvel.une.edu.au>...
> I need to select from a table where two columns are duplicated. I know
> this may be really simple but if someone can help me out I'd appreciate
> it.
>
> eg. select a,b from table where a and b are duplicated (occur in more
 than
> one row)
>
> TIA
>
> Brian
> bcamero5_at_metz.une.edu.au
>
>
  Received on Fri Feb 07 1997 - 00:00:00 CST

Original text of this message

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