0
0
SQLquery~5 mins

ORDER BY single column in SQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AGROUP BY
BORDER BY
CWHERE
DHAVING
What is the default sort order when using ORDER BY without ASC or DESC?
ADescending
BRandom
CAscending
DNo sorting
How do you sort results by the column age in descending order?
AORDER BY age DESC
BORDER BY age ASC
CORDER BY DESC age
DSORT BY age DESC
Can you use ORDER BY on a column not included in the SELECT statement?
AOnly in MySQL
BNo
COnly if the column is indexed
DYes
Which keyword sorts data from smallest to largest?
AASC
BORDER
CSORT
DDESC
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.