Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Your first view
How to use views
Summary
12. Review

Instruction

Here's the review question!

Exercise

You're given two tables from a taxi corporation: taxi_driver and city:

CREATE TABLE city (
  id integer PRIMARY KEY,
  name varchar(64)
);

CREATE TABLE taxi_driver (
  id integer PRIMARY KEY,
  full_name varchar(128),
  salary decimal(10, 2),
  city_id integer,
  FOREIGN KEY (city_id)
  REFERENCES city(id)
);

As you can see, each taxi driver works in a single city. Your task is to write a view named avg_salary_city that will contain two columns:

  1. name – the city name.
  2. avg_salary – the average of all drivers' salaries in that city.