ORDER BY & Sorting SQL Topic exerciseEasyVerified answerSQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

Show Most Recent Hires First

Return first_name, last_name, and hire_date for every employee, ordered from the most recent hire to the oldest.

  • Sorting

Exercise brief

Understand the request

People operations coordinator An onboarding review needs the newest hires at the top of the report.

List employees sorted so that the most recently hired appears first. Show first_name, last_name, hire_date.

Return

  • Return one row per employee.
  • Order dates from newest to oldest.

Constraints

  • Sort hire_date descending.

Data you will use

Review the relevant tables before deciding how to join, filter, or aggregate them.

employees

  • first_nameTEXT
  • last_nameTEXT
  • hire_dateDATE

Hints, when you need them

Open one clue at a time so you still do the reasoning.

Hint 1

Dates sort chronologically — earlier dates are "smaller", later dates are "larger".

Hint 2

Most-recent-first means DESC. Oldest-first is ASC.

Hint 3

ORDER BY hire_date DESC

Verified SQL answer

Attempt the problem first, then compare structure and reasoning—not just syntax.

Reveal solution and explanation
SELECT first_name, last_name, hire_date FROM employees ORDER BY hire_date DESC;

Why this works

Date columns stored as DATE/DATETIME sort correctly out of the box. Date STRINGS in `YYYY-MM-DD` format also sort correctly (lexicographic = chronological). Avoid storing dates as `MM/DD/YYYY` strings — they sort wrong.

Success check

The latest hire is first and the earliest hire is last.

Expected result

Use this output to verify values, aliases, ordering, and row count.

first_namelast_namehire_date
EmmaThomas2023-01-10
DavidBrown2022-02-28
AmyTaylor2021-12-03
MikeJohnson2021-06-10
RachelGarcia2020-11-30
LisaDavis2020-09-12
ChrisAnderson2020-04-25
JohnDoe2020-01-15
AlexMiller2019-08-14
TomWilson2019-07-18

Previewing 10 of 12 expected rows. Run the query in the editor to inspect the full result.

Learn the concepts behind this answer

Strengthen your understanding with these targeted learning topics:

Continue practicing

SQL Practice Online

Open the interactive workspace and practice across SQL topics.