Introduction
Dealing with dates
Working with time data
Date and time date
21. Practice time!
Extracting dates and times
Doing arithmetic with dates
Converting date and time data
Current date and time data
Building date and time data from parts
Summary and review

Instruction

Jolly good! Let's do one more exercise before we move on.

Exercise

Find all aircraft that were launched before January 1, 2014 and took more than one flight. For each aircraft, show its ID (as Id) and calculate the average distance covered on all its routes. Name the column AvgDistance.

Stuck? Here's a hint!

  • Use AVG(x) to find the average value of x.
  • Remember about the proper date format and use quotes: 'YYYY-MM-DD'.
  • Use HAVING with COUNT(x) after GROUP BY to satisfy the condition for more than 1 flight.