SOUNDEX()로 이름 비교하기
데이터를 분석할 때 'Illinois' 대신 'Ilynois'처럼 지저분한 문자열이 있으면 문제가 생길 수 있어요. 그래서 이런 값을 찾아내는 게 중요합니다.
flight_statistics 테이블을 분석해 보니, 일부 statistician_name과 statistician_surname이 서로 다르게 적혀 있네요. 예를 들어 Miriam Smith와 Myriam Smyth처럼요. 이런 차이가 더 있을까 봐, 모든 이름을 점검하고 싶습니다.
통계학자들의 이름을 SOUNDEX()로 비교해 보려 합니다. SOUNDEX() 결과는 같지만 실제 텍스트가 다르면, 정리해야 할 데이터를 찾을 수 있습니다.
이 연습은 강의의 일부입니다
SQL Server 데이터베이스에서 데이터 정제하기
연습 안내
S1에서statistician_name과statistician_surname컬럼의 고유한 값들을 선택하세요.SOUNDEX()를 사용해 비슷한 발음의 이름과 성을 기준으로flight_statistics테이블을S2로 내부 조인하세요.S1과S2각각에서statistician_name과statistician_surname값이 서로 다른 행만 남기도록 필터링하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
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.___