Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Dealing with dates
9. Sorting dates with ORDER BY
Working with time data
Date and time date
Extracting dates and times
Doing arithmetic with dates
Converting date and time data
Building date and time data from parts
Summary and review

Instruction

Nice job! You can also sort your rows by date using ORDER BY:

SELECT
  Id,
  Model,
  ProducedDate
FROM Aircraft
WHERE ProducedDate BETWEEN '2009-01-01' AND '2010-12-31'
ORDER BY ProducedDate;

As usual, you can add ASC (the default sort order) or DESC after the ORDER BY clause to define the sort order.

Exercise

Select the Id and Date of all flights in 2015 and sort them, putting the most recent first.

Stuck? Here's a hint!

Remember about the proper date format and use quotes: 'YYYY-MM-DD'. Sorting recent dates first means DESCending order.