Look for Duplicates

Results 1 to 2 of 2

Thread: Look for Duplicates

  1. #1
    Join Date
    Dec 1969

    Default Look for Duplicates

    In SQL 7, how do I look for duplicates? I know that I can use DISTINCT to return only 1 of each record, but I want to actually find duplicates.

  2. #2
    Join Date
    Dec 1969

    Default You can simply GROUP BY your keys...

    lets say I have following table and columns:<BR><BR>mytable<BR>-----------<BR>col1<BR>col2<BR>col3<BR><BR>and col1 and col2 are my keys then<BR><BR>SELECT col1, col2, col3, count(col1)<BR>FROM mytable<BR>GROUP BY col1,col2,col3<BR>HAVING count(col1) &#062; 1<BR><BR>As you can see anything with a count greater than 1 will be your duplicates.<BR><BR>Hope that helps<BR><BR>Pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts