| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
|  |  | |||
Home -> Community -> Usenet -> c.d.o.misc -> Re: Very Simple SQL question ... hepl ? ...
You expected output will appear with this query::
select distinct a.lastname,count(*) 
from names a, names b
where a.rowid <> b.rowid
and a.lastname=b.lastname
group by a.n
Let me know if this helped.
Chinna
Anon <pjbump_at_i1.net> wrote in article
<01bcc5e8$e8e46ce0$d33ae6cf_at_default>...
> SELECT A.last_name, A.pid
>   FROM tablex A, tablex B
>  WHERE A.last_name = B.last_name
>    and A.rowid <> B.rowid;
> -- 
> Phillip Bump
> Senior Principal Consultant
> Oracle Consulting
>
> -----------------------------------------------------------------------
> The opinions expressed are my own and do not necessarily reflect those of
> Oracle Corporation
> 
> Hank Griffioen <hank_at_daac.gsfc.nasa.gov> wrote in article
> <34201C6E.CF4C987B_at_daac.gsfc.nasa.gov>...
> > I have a table called names that has last_name and pid in
> >   the table.  I am tryint to find a simple query that 
> >   will all me to select all rows that have duplicated last names.
> > 
> >    For example
> > 
> >         last_name       pid
> >        --------------------------
> >          smith           1
> >          smith           3
> >          jones           4
> >          griffin         5
> >          stevens         6
> >          stevens         7
> > 
> >      I want to do the opposite of distinct.
> >   
> >      something like ....
> >        select duplicate last_name pid from person.
> > 
> >          smith           1
> >          smith           3
> >          stevens         6
> >          stevens         7
> > 
> > 
> > -- 
> > Hank Griffioen  CFII,MEII,AGI,IGI   INTERNET:
> > hank_at_daacdev1.nasa.gsfc.gov
> > GSFC BLD 32 Code 902.2                fax        614-5304
> > Greenbelt, MD  20770                  Phone: 301-614-5488
> > To order CD-ROMs and data    URL = http://daac.gsfc.nasa.gov/
> > NASA Goddard Flying Club     URL = http://daac.gsfc.nasa.gov/NGFC/
> >     (***I do not speak for HSTX, NASA or NASA Goddard Flying Club***)
> > 
> 
 
Received on Mon Sep 22 1997 - 00:00:00 CDT
|  |  |