Write SQL Query to find employees that have same name and email.

Employee table:

ID NAME EMAIL
10 John jbaldwin
20 George gadams
30 John jsmith

Answer: This is a simple question with one trick. The trick here is to use Group by on two columns Name and Email.

Query would be as follows:

SELECT name, email, COUNT()
FROM Employee
GROUP BY name, email
HAVING
COUNT(
) > 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 *

*