ComenzarEmpieza gratis

Comparar nombres con SOUNDEX()

Cadenas desordenadas como 'Ilynois' en lugar de 'Illinois' pueden causar problemas al analizar datos. Por eso es importante detectarlas.

Al analizar la tabla flight_statistics, te das cuenta de que algunos statistician_name y statistician_surname están escritos de forma diferente, como Miriam Smith y Myriam Smyth. Te preocupa que haya más diferencias así, así que quieres revisar todos estos nombres.

Piensas en comparar los nombres de las personas estadísticas con SOUNDEX(). Si el resultado de SOUNDEX() es el mismo pero los textos que comparas son distintos, encontrarás los datos que necesitas limpiar.

Este ejercicio forma parte del curso

Limpieza de datos en bases de datos SQL Server

Ver curso

Instrucciones del ejercicio

  • Selecciona los valores distintos de las columnas statistician_name y statistician_surname de S1.
  • Haz un INNER JOIN de la tabla flight_statistics como S2 usando SOUNDEX() para emparejar nombres y apellidos que suenen parecido.
  • Excluye los valores donde las columnas statistician_name y statistician_surname sean diferentes entre S1 y S2, respectivamente.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

SELECT 
    -- First name and surname of the statisticians
	DISTINCT S1.___, S1.___
-- Join flight_statistics with itself
FROM ___ S1 INNER JOIN ___ S2 
	-- The SOUNDEX result of the first name and surname have to be the same
	ON ___(S1.___) = ___(S2.___) 
	AND ___(S1.___) = ___(S2.___) 
-- The texts of the first name or the texts of the surname have to be different
WHERE S1.___ <> S2.___
	OR S1.___ <> S2.___
Editar y ejecutar código