Recall & Review
beginner
What does the SQL clause
ORDER BY do?It sorts the rows returned by a query based on one or more columns, either in ascending or descending order.
Click to reveal answer
beginner
How do you sort query results by a single column in ascending order?
Use
ORDER BY column_name ASC. ASC means ascending order and is the default if not specified.Click to reveal answer
beginner
How do you sort query results by a single column in descending order?
Use
ORDER BY column_name DESC. DESC means descending order.Click to reveal answer
beginner
What happens if you use
ORDER BY without specifying ASC or DESC?The results are sorted in ascending order by default.
Click to reveal answer
intermediate
Can
ORDER BY be used with columns not in the SELECT list?Yes, you can order by any column in the table, even if it is not selected in the output.
Click to reveal answer
Which SQL clause sorts the results by a single column?
✗ Incorrect
ORDER BY sorts the query results by one or more columns.
What is the default sort order when using
ORDER BY without ASC or DESC?✗ Incorrect
By default, ORDER BY sorts in ascending order.
How do you sort results by the column
age in descending order?✗ Incorrect
The correct syntax is ORDER BY age DESC.
Can you use
ORDER BY on a column not included in the SELECT statement?✗ Incorrect
You can order by any column in the table, even if it is not selected.
Which keyword sorts data from smallest to largest?
✗ Incorrect
ASC sorts data in ascending order (smallest to largest).
Explain how to sort query results by a single column in SQL.
Think about the clause that controls the order of rows.
You got /4 concepts.
What happens if you use ORDER BY on a column not included in the SELECT list?
Consider if the column must appear in the output to sort by it.
You got /3 concepts.