0
0
SQLquery~5 mins

ORDER BY with ASC and DESC in SQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the ORDER BY clause do in SQL?
It sorts the rows returned by a query based on one or more columns.
Click to reveal answer
beginner
What is the default sorting order when using ORDER BY without specifying ASC or DESC?
The default sorting order is ascending (ASC).
Click to reveal answer
beginner
How do you sort query results in descending order?
Use ORDER BY column_name DESC to sort results from highest to lowest or Z to A.
Click to reveal answer
intermediate
Can you sort by multiple columns using ORDER BY? How?
Yes. List columns separated by commas, e.g., ORDER BY column1 ASC, column2 DESC.
Click to reveal answer
intermediate
What happens if you mix ASC and DESC in the same ORDER BY clause?
Each column sorts independently in the specified order, e.g., first ascending, then descending.
Click to reveal answer
What does ORDER BY name DESC do?
ASorts names from A to Z
BSorts names from Z to A
CFilters names starting with D
DGroups names by letter
Which is the correct way to sort by age ascending and then by name descending?
AORDER BY age ASC, name DESC
BORDER BY age, name
CORDER BY name DESC, age ASC
DORDER BY age DESC, name ASC
If you write ORDER BY salary without ASC or DESC, what happens?
ANo sorting applied
BSorts salary descending
CSorts salary ascending
DCauses an error
Can ORDER BY sort by columns not in the SELECT list?
AYes, always
BOnly if using GROUP BY
CNo, never
DDepends on SQL dialect
What is the effect of ORDER BY date DESC, price ASC?
ASorts by date descending, then price ascending
BSorts by date ascending, then price descending
CSorts by price descending, then date ascending
DSorts by price ascending only
Explain how to use ORDER BY to sort query results by multiple columns with different orders.
Think about sorting a list first by one rule, then by another.
You got /4 concepts.
    Describe what happens if you omit ASC or DESC in an ORDER BY clause.
    What is the usual way to sort numbers or letters?
    You got /3 concepts.