Write Query to find employees with duplicate email.

Employee table:
ID NAME EMAIL
10 John jsmith
20 George gadams
30 Jane jsmith

Answer: We can use Group by clause on the column in which we want to find duplicate values.

Query would be as follows:

SELECT name, COUNT(email)
FROM Employee
GROUP BY email
HAVING ( COUNT(email) > 1 )

Read the full book at www.amazon.com
Posted in SQL, SQL Interview Questions

Leave a Reply

Your email address will not be published. Required fields are marked *

*