Confrontare i nomi con SOUNDEX()
Stringhe disordinate come 'Ilynois' invece di 'Illinois' possono creare problemi nell'analisi dei dati. Per questo è importante individuarle.
Analizzando la tabella flight_statistics, ti accorgi che alcuni statistician_name e statistician_surname sono scritti in modo diverso, ad esempio Miriam Smith e Myriam Smyth. T temi che ci siano altre differenze di questo tipo, quindi vuoi controllare tutti questi nomi.
Stai pensando di confrontare con SOUNDEX() i nomi degli statistici. Se il risultato di SOUNDEX() è lo stesso, ma i testi che stai confrontando sono diversi, troverai i dati che devi pulire.
Questo esercizio fa parte del corso
Pulizia dei dati nei database SQL Server
Istruzioni dell'esercizio
- Seleziona i valori distinti delle colonne
statistician_nameestatistician_surnamedaS1. - Esegui un inner join della tabella
flight_statisticscomeS2su nomi e cognomi con suono simile usandoSOUNDEX(). - Escludi i valori in cui le colonne
statistician_nameestatistician_surnamesono diverse traS1eS2, rispettivamente.
Esercizio pratico interattivo
Prova a risolvere questo esercizio completando il codice di esempio.
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.___