Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have a table named CUSTOMER and it has columns FirstName, LastName, Phone, and

ID: 669045 • Letter: I

Question

I have a table named CUSTOMER and it has columns FirstName, LastName, Phone, and Email.

The question I have to perform is:

List only those customers who have the same name (First and Last). Use a subquery.

I can use a subquery to go through and find common first names. How do I add the last name to the subquery so that I can find an exact match of first and last? My code below finds first name matches. Thanks for the help...

SELECT FirstName

FROM CUSTOMER

WHERE FirstName in (SELECT FirstName FROM CUSTOMER GROUP BY FirstName HAVING COUNT(FirstName) > 1);

Explanation / Answer

SELECT a.* FROM CUSTOMERS a WHERE a.FirstName IN (SELECT b.FirstName FROM CUSTOMERS b WHERE (b.FirstName = a.FirstName and b.LastName = a.LastName ) GROUP BY b.FirstName having COUNT(b.FirstName ) > 1) order by a.FirstName;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote