Home All Groups Group Topic Archive Search About

extract non-unique records from a table

Author
6 Jan 2006 12:01 PM
Shekhar Gupta
Can anyone pls help me with any SQL syntax / logic of extracting only the
non-unique records from an SQL table ?

Thanks
Shekhar

Author
6 Jan 2006 12:05 PM
Ryan
If i understand correctly you're after a query that returns the duplicates.
If so give this a try :-

SELECT Col001, COUNT(*) FROM tablename
GROUP BY Col001
HAVING COUNT(*) > 1

This will return any Col001 that are duplicate

--
HTH. Ryan


Show quote
"Shekhar Gupta" <ShekharGu***@discussions.microsoft.com> wrote in message
news:38DC7E2D-051B-4573-9C9A-5B6164F99E78@microsoft.com...
> Can anyone pls help me with any SQL syntax / logic of extracting only the
> non-unique records from an SQL table ?
>
> Thanks
> Shekhar
Author
6 Jan 2006 12:17 PM
Shekhar Gupta
gr8, Thanks Ryan, this worked

shekhar

Show quote
"Ryan" wrote:

> If i understand correctly you're after a query that returns the duplicates.
> If so give this a try :-
>
> SELECT Col001, COUNT(*) FROM tablename
> GROUP BY Col001
> HAVING COUNT(*) > 1
>
> This will return any Col001 that are duplicate
>
> --
> HTH. Ryan
>
>
> "Shekhar Gupta" <ShekharGu***@discussions.microsoft.com> wrote in message
> news:38DC7E2D-051B-4573-9C9A-5B6164F99E78@microsoft.com...
> > Can anyone pls help me with any SQL syntax / logic of extracting only the
> > non-unique records from an SQL table ?
> >
> > Thanks
> > Shekhar
>
>
>

AddThis Social Bookmark Button