ComeçarComece de graça

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_color values that are similar to RED, BLUE, or YELLOW.
  • Handle both the ambiguous vehicle_color value BL and the incorrectly identified vehicle_color value BLA using pattern matching.
  • Update the vehicle_color values with strong similarity to RED, BLUE, or YELLOW to the standard string values.

Este exercício faz parte do curso

Cleaning Data in PostgreSQL Databases

Ver curso

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

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
		___(___, ___) = ___
	)
Editar e executar o código