How do you sort employees by hire_date descending?

Study for the SQL Basics Test. Improve your knowledge with multiple choice questions and detailed explanations. Prepare effectively to master SQL concepts!

Multiple Choice

How do you sort employees by hire_date descending?

Explanation:
Sorting results by a column is done with ORDER BY. To get the most recently hired employees first, use DESC for descending order. So, to list employees from newest hire date to oldest, the query is SELECT * FROM employees ORDER BY hire_date DESC;. This returns all columns for each employee, but ordered from the latest hire date to the earliest. Using ASC would flip the order to oldest first, omitting the direction defaults to ascending in many databases, and SORT BY isn’t valid SQL syntax.

Sorting results by a column is done with ORDER BY. To get the most recently hired employees first, use DESC for descending order. So, to list employees from newest hire date to oldest, the query is SELECT * FROM employees ORDER BY hire_date DESC;. This returns all columns for each employee, but ordered from the latest hire date to the earliest.

Using ASC would flip the order to oldest first, omitting the direction defaults to ascending in many databases, and SORT BY isn’t valid SQL syntax.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy