Standardizing multiple colors
After the success of standardizing the naming of GRAY-colored vehicles, you decide to extend this approach to additional colors. The primary colors RED, BLUE, and YELLOW will be used for extending the color name standardization approach. In this exercise, you will:
- Find
vehicle_colorvalues that are similar toRED,BLUE, orYELLOW. - Handle both the ambiguous
vehicle_colorvalueBLand the incorrectly identifiedvehicle_colorvalueBLAusing pattern matching. - Update the
vehicle_colorvalues with strong similarity toRED,BLUE, orYELLOWto the standard string values.
この演習はコースの一部です
Cleaning Data in PostgreSQL Databases
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
SELECT
summons_number,
vehicle_color,
-- Include the DIFFERENCE() value for each color
___(vehicle_color, 'RED') AS "red",
___(___, 'BLUE') AS "blue",
___(___, ___) AS "yellow"
FROM
parking_violation
WHERE
(
-- Condition records on DIFFERENCE() value of 4
DIFFERENCE(vehicle_color, 'RED') = 4 OR
___(___, ___) = ___ OR
___(___, ___) = ___
)