Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Querying for duplicate names
Message
From
07/09/2014 00:29:19
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Other
Title:
Querying for duplicate names
Environment versions
SQL Server:
SQL Server 2014
Application:
Web
Miscellaneous
Thread ID:
01607128
Message ID:
01607128
Views:
78
I have a list of people that I need to do a duplicate name check on and display the results along with the IDs. I was going to do a simple GROUP BY, but then I'd have to join back to the original table to get the ID. Is there something sexier? (11:30 on a Saturday night and I'm asking about sexy SQL queries....)
SELECT
	*
FROM
	Users users
		INNER JOIN (
					SELECT
						FirstName, LastName
					FROM
						Users
					GROUP BY
						FirstName, LastName
					HAVING
						COUNT(*) > 1
				   ) un ON (un.FirstName = users.FirstName AND un.LastName = users.LastName)
Very fitting: http://xkcd.com/386/
Next
Reply
Map
View

Click here to load this message in the networking platform