LoslegenKostenlos loslegen

Matching inconsistent color names

From the sample of records in the parking_violation table, it is clear that the vehicle_color values are not consistent. For example, 'GRY', 'GRAY', and 'GREY' are all used to describe a gray vehicle. In order to consistently represent this color, it is beneficial to use a single value. Fortunately, the DIFFERENCE() function can be used to accomplish this goal.

In this exercise, you will use the DIFFERENCE() function to return records that contain a vehicle_color value that closely matches the string 'GRAY'. The fuzzystrmatch module has already been enabled for you.

Diese Übung ist Teil des Kurses

Cleaning Data in PostgreSQL Databases

Kurs anzeigen

Anleitung zur Übung

  • Use the DIFFERENCE() function to find parking_violation records having a vehicle_color with a Soundex code that matches the Soundex code for 'GRAY'. Recall that the DIFFERENCE() function accepts string values (not Soundex codes) as parameter arguments.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

SELECT
  summons_number,
  vehicle_color
FROM
  parking_violation
WHERE
  -- Match SOUNDEX codes of vehicle_color and 'GRAY'
  ___(___, ___) = ___;
Code bearbeiten und ausführen