4

I am trying to find out how many duplicate records I have in a table. I can use count, but I'm not sure how best to eliminate records where the count is only 1.

select first_name, last_name, start_date, count(1)
from employee
group by first_name, last_name, start_date;

I can try to order by the count, but I am still not eliminating those with a count of one.

1 Answer 1

5

you can use having clause as having Count(*) > 1 after group by like this :

select 
  first_name, 
  last_name, 
  start_date,
  Count(*) AS Count
from 
  employee 
group by 
  first_name, 
  last_name, 
  start_date
having 
  Count(*) > 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.