Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Querying for duplicate names
Message
De
07/09/2014 00:29:19
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Titre:
Querying for duplicate names
Versions des environnements
SQL Server:
SQL Server 2014
Application:
Web
Divers
Thread ID:
01607128
Message ID:
01607128
Vues:
76
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/
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform