2

How do I get the number of dumplicate data in a table.

Example: I have these datas in a table.

ID: 1 2 3 4 5
Score: 100 300 400 100 300

I want the result to be 2 because 100 has a duplicate andalso 300, so that gives the result to be 2.

I'm thinking of a group by and count aggregate function. But it won't work because it will include 400 even if it doesn't have duplicate data.

How would I do t that?

Your help would be greatly appreciated. Thanks!

1 Answer 1

5

You need to use a GROUP BY as well as a HAVING clause. Like this:

SELECT COUNT(*)
FROM table
GROUP BY Score
HAVING COUNT(Score) > 1
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.