ComeçarComece de graça

Identifying out-of-range vehicle model years

Type constraints are useful for restricting the type of data that can be stored in a table column. However, there are limitations to how thoroughly these constraints can prevent invalid data from entering the column. Range constraints are useful when the goal is to identify column values that are included in a range of values or excluded from a range of values. Using type constraints when defining a table followed by checking column values with range constraints are a powerful approach to ensuring the integrity of data.

In this exercise, you will use a BETWEEN clause to build a range constraint to identify invalid vehicle model years in the parking_violation table. Valid vehicle model years for this dataset are considered to be between 1970 and 2021.

Este exercício faz parte do curso

Cleaning Data in PostgreSQL Databases

Ver curso

Instruções do exercício

  • Write a query that returns the summons_number, plate_id, and vehicle_year for records in the parking_violation table containing a vehicle_year outside of the range 1970-2021.

Exercício interativo prático

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

SELECT
  -- Define the columns to return from the query
  ___,
  ___,
  ___
FROM
  parking_violation
WHERE
  -- Define the range constraint for invalid vehicle years
  ___ NOT ___ ___ AND ___;
Editar e executar o código