Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL, the opposite of SELECT DISTINCT? 2

Status
Not open for further replies.

SoupXVII

Technical User
Dec 15, 2000
36
IT
I know how to use select distinct, but I would like to select "non-distinct" records, those that have duplicate values in a given field. How is that possible in SQL?
 
Use a group by query with a count on the field with the dups. Then select only the records with count > 1.

Something like this:

SELECT * FROM <tablename>
WHERE dupfield In (SELECT dupfield
FROM <tablename>
GROUP BY dupfield
HAVING Count(dupfield)>1);
Maq [americanflag]
<insert witty signature here>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top