• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 41
  • Last Modified:

SQL Select - FInding duplicate records

I just need to help finding duplicate records within a table.  

Need to find all records that the same UPC and Part Number.  

Here is a sample of my table:
Name     UPC       Part Number
---------     ------       ------------------
Test        123         ABC
Black      123         ABC                          
Orange   199        CDE
Yellow     821        FEL
Cyan        199        CDE

The expected results:

Name     UPC       Part Number
---------     ------       ------------------
Test        123         ABC
Black      123         ABC                          
Orange   199        CDE
Cyan        199        CDE
0
tmajor99
Asked:
tmajor99
1 Solution
 
von AxlSystem AdministratorCommented:
SELECT DISTINCT column1, column2, ...
FROM table_name;
0
 
David SankovskySenior SysAdminCommented:
SELECT
    name, COUNT(*)
FROM
    table_name
GROUP BY
    upc, part number
HAVING 
    COUNT(*) > 1

Open in new window

0
 
Dale FyeCommented:
SELECT yourTable.*
FROM yourTable
INNER JOIN (
SELECT UPC, [Part_Number] FROM yourTable GROUP BY UPC, Part_Number HAVING Count(*) > 1
) as Dups
ON yourTable.UPC = Dups.UPC and yourTable.[Part_Number] = Dups.[Part_Number]
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now