Welcome Back

Google icon Sign in with Google
OR
I agree to abide by Pharmadaily Terms of Service and its Privacy Policy

Create Account

Google icon Sign up with Google
OR
By signing up, you agree to our Terms of Service and Privacy Policy
Instagram
youtube
Facebook

Find Duplicate Products by Name

Find Duplicate Products by Name

Producrs Table:


Explanation:

  • GROUP BY ProductName:
    Groups products by their name.

  • COUNT(*):
    Counts how many times each product name appears.

  • HAVING COUNT(*) > 1:
    Filters only those names that appear more than once — i.e., duplicates.

  • SELECT ProductName, COUNT(*):
    Shows the name and how many times it’s repeated.

    SQL Query:

    SELECT 
        ProductName, 
        COUNT(*) AS DuplicateCount
    FROM 
        Products
    GROUP BY 
        ProductName
    HAVING 
        COUNT(*) > 1;
    


    Output: