Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
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
Building date and time data from parts
Summary and review


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


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.