Link to home
Start Free TrialLog in
Avatar of HLRosenberger
HLRosenbergerFlag for United States of America

asked on

Help with SQL - query name records

I have a table of employees, first, middle and last name columns along with other info.  I want to query a list of all records where the first, middle and last name are the same, grouping by the same.  There are also two other columns I want returned in the results, call them ID1 and ID2, and that will be different for each record. -  How can I do this?
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Based on the requirements in your question, give this a whirl...
SELECT firstname, middlename, lastname, ID1, ID2
FROM yourtable 
WHERE  firstname = middlename AND middlename = lastname

Open in new window


>I want to query a list of all records where the first, middle and last name are the same, grouping by the same.
if there's anything missing, please spell it out.  I suspect that the above is missing some detail.
Avatar of HLRosenberger

ASKER

I did not articulate my  question correctly.  Let me use an example; say I have these records:

Harold L Rosenberger  123  456
Harold L Rosenberger 111 333
Mary Jones 333 444
George Washington 333 444
George Washington 555 666
George Washington 123 877
George R Washington 155 876
Gary Lee Rogers 555 120

I want these records returned:

Harold L Rosenberger  123  456
Harold L Rosenberger 111 333
George Washington 333 444
George Washington 555 666
George Washington 123 877
ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
that works, except for one case, where the middle name is NULL.   How could I modify to handle this?
yeah, can't do a NULL = NULL, so a simple ISNULL conversion will work.  
Change 'x' to whatever floats your boat.
I modified the code block above to keep the solution in one comment.
Thanks!!
Thanks for the grade.  Good luck with your project.  -Jim