I'm working on the following SQL for a query:
SELECT PERSON_NAME.Person_id, PERSON_NAME.delete, PERSON_NAME.Lastname_name_local1, PERSON_NAME.Person_name_id, PERSON_NAME.Middle_name, PERSON_NAME.Name_suffix
FROM PERSON_NAME
WHERE (((PERSON_NAME.person_id) In (SELECT [person_id] FROM [PERSON_NAME] As Tmp GROUP BY [person_id] HAVING Count(*)>1 )))
ORDER BY PERSON_NAME.Person_id;
I simply want to add to this code the ability to select not only person_id's that have a count greater that one, I want to select both person_id's AND lastname's that have a count greater than one. What should I do to improve the code?
SELECT PERSON_NAME.Person_id, PERSON_NAME.delete, PERSON_NAME.Lastname_name_local1, PERSON_NAME.Person_name_id, PERSON_NAME.Middle_name, PERSON_NAME.Name_suffix
FROM PERSON_NAME
WHERE (((PERSON_NAME.person_id) In (SELECT [person_id] FROM [PERSON_NAME] As Tmp GROUP BY [person_id] HAVING Count(*)>1 )))
ORDER BY PERSON_NAME.Person_id;
I simply want to add to this code the ability to select not only person_id's that have a count greater that one, I want to select both person_id's AND lastname's that have a count greater than one. What should I do to improve the code?