Activity: SQL practice

(no submission)
Purpose:

You may make a copy of a activity-sql-practice.sql and complete this activity.

You may work alone or with at most 2 other students (max size=3) in this course.


Use an SQL script cardata.sql to create and populate three tables of the US vehicle toy database. (data from https://www.kaggle.com/datasets/doaaalsenani/usa-cers-dataset?resource=download)

Write SQL queries to solve the following problems.

  1. Find all vehicle brands with the registration years after 2015 that are listed for the state of Virginia. Do not repeat the names of the brands.
  2. Find the numbers of vehicles by year. Display only the year with at least 100 vehicles.
  3. Find the counts of vehicle brands listed in each state. Sort the result by states.
  4. Find the counts of colors for all Jeep MPVs. Display the color and the count of each color.
    • You should consider the number of vehicles in each color; for example, if three Jeep MPVs are black, the count of black color is 3.
  5. List VINs of the vehicles with the most expensive price in each state. If there are multiple vehicles with the most expensive price in the state, list them all. Display VINs, states, and prices. Sort the information by state.
  6. Find all the brands and models of vehicles with prices between 20,000 and 50,000 (inclusive). Only consider the vehicles that have less than 10,000 miles. Display VIN, brand, model, price, and mileage.


Copyright © 2024 Upsorn Praphamontripong

Released under the Creative Commons License CC-BY-NC-SA 4.0 license.

Last updated 2024-02-22 19:41