ASC means ascending order. It sorts data from smallest to largest, like A to Z or 1 to 10.
Click to reveal answer
beginner
What does DESC mean in SQL ORDER BY clause?
DESC means descending order. It sorts data from largest to smallest, like Z to A or 10 to 1.
Click to reveal answer
beginner
How do you sort a list of names in descending order in SQL?
Use ORDER BY column_name DESC. For example: SELECT name FROM users ORDER BY name DESC;
Click to reveal answer
beginner
If you want to sort numbers from smallest to largest, which keyword do you use?
Use ASC to sort numbers from smallest to largest.
Click to reveal answer
beginner
What is the default sorting order if you do not specify ASC or DESC?
The default sorting order is ASC (ascending).
Click to reveal answer
Which keyword sorts data from largest to smallest?
AASC
BORDER
CDESC
DSORT
✗ Incorrect
DESC sorts data in descending order, from largest to smallest.
What is the default order when using ORDER BY without ASC or DESC?
ADESC
BASC
CRandom
DNo order
✗ Incorrect
The default order is ASC, which means ascending order.
How would you sort a column named 'age' from youngest to oldest?
AORDER BY age DESC
BORDER BY age RANDOM
CORDER BY age
DORDER BY age ASC
✗ Incorrect
ORDER BY age ASC sorts from smallest (youngest) to largest (oldest).
Which of these is a valid SQL clause to sort data?
AORDER BY column_name ASC
BSORT BY column_name
CFILTER BY column_name DESC
DGROUP BY column_name ASC
✗ Incorrect
ORDER BY with ASC or DESC is the correct syntax to sort data.
If you want to see the highest scores first, which ORDER BY clause do you use?
AORDER BY score DESC
BORDER BY score ASC
CORDER BY score RANDOM
DORDER BY score
✗ Incorrect
ORDER BY score DESC shows highest scores first.
Explain the difference between ASC and DESC in SQL sorting.
Think about how you arrange numbers or words from A to Z or Z to A.
You got /4 concepts.
How do you write a query to sort a list of products by price from highest to lowest?
Remember DESC means descending order.
You got /3 concepts.
Practice
(1/5)
1. What does the ASC keyword do in a MySQL ORDER BY clause?
easy
A. Filters the data to show only ascending values
B. Sorts the data from largest to smallest or Z to A
C. Groups the data by ascending order
D. Sorts the data from smallest to largest or A to Z
Solution
Step 1: Understand the meaning of ASC in ORDER BY
ASC stands for ascending order, which means sorting from smallest to largest or alphabetically from A to Z.
Step 2: Compare with other options
DESC is for descending order, filtering and grouping are different SQL operations unrelated to ASC.
Final Answer:
Sorts the data from smallest to largest or A to Z -> Option D
Quick Check:
ASC = ascending order = smallest to largest [OK]
Hint: ASC means ascending order: smallest to largest [OK]
Common Mistakes:
Confusing ASC with DESC
Thinking ASC filters data
Mixing sorting with grouping
2. Which of the following is the correct syntax to sort a table named employees by the salary column in descending order?
easy
A. SELECT * FROM employees ORDER BY salary DESC;
B. SELECT * FROM employees ORDER BY salary ASC;
C. SELECT * FROM employees ORDER salary DESC;
D. SELECT * FROM employees SORT BY salary DESC;
Solution
Step 1: Identify correct ORDER BY syntax
The correct syntax to sort results is using ORDER BY followed by the column name and then ASC or DESC.
Step 2: Check each option
SELECT * FROM employees ORDER BY salary ASC; uses ASC, not DESC. SELECT * FROM employees ORDER salary DESC; misses BY keyword. SELECT * FROM employees SORT BY salary DESC; uses SORT BY which is invalid in MySQL. SELECT * FROM employees ORDER BY salary DESC; is correct.
Final Answer:
SELECT * FROM employees ORDER BY salary DESC; -> Option A
Quick Check:
ORDER BY + column + DESC is correct syntax [OK]
Hint: Use ORDER BY column DESC to sort descending [OK]
Common Mistakes:
Omitting BY after ORDER
Using SORT BY instead of ORDER BY
Mixing ASC and DESC keywords
3. Given the table products with column price, what will be the order of prices returned by this query?
SELECT price FROM products ORDER BY price DESC;
medium
A. Prices sorted randomly
B. Prices sorted from lowest to highest
C. Prices sorted from highest to lowest
D. Prices grouped by price value
Solution
Step 1: Analyze ORDER BY with DESC
ORDER BY price DESC sorts the prices from the largest value to the smallest value.
Step 2: Eliminate other options
Prices sorted from lowest to highest is ascending order, Prices sorted randomly is incorrect because ORDER BY sorts results, Prices grouped by price value is grouping which is unrelated.
Final Answer:
Prices sorted from highest to lowest -> Option C
Quick Check:
DESC means descending order = highest to lowest [OK]
Hint: DESC sorts from highest to lowest [OK]
Common Mistakes:
Confusing DESC with ASC
Expecting random order without ORDER BY
Thinking ORDER BY groups data
4. Identify the error in this query that tries to sort students by age in descending order:
SELECT * FROM students ORDER age DESC;
medium
A. The table name students is invalid
B. Missing BY keyword after ORDER
C. ORDER BY should be replaced with SORT BY
D. DESC cannot be used with ORDER
Solution
Step 1: Check ORDER BY syntax
The correct syntax requires ORDER BY, not just ORDER, before the column name.
Step 2: Validate other parts
DESC is valid with ORDER BY. SORT BY is not valid in MySQL. Table name is valid as given.
Final Answer:
Missing BY keyword after ORDER -> Option B
Quick Check:
ORDER BY is required, not just ORDER [OK]
Hint: Always use ORDER BY, not just ORDER [OK]
Common Mistakes:
Omitting BY after ORDER
Using SORT BY instead of ORDER BY
Misunderstanding DESC usage
5. You want to list all orders sorted first by order_date ascending, then by total_amount descending. Which query correctly achieves this?
hard
A. SELECT * FROM orders ORDER BY order_date ASC, total_amount DESC;
B. SELECT * FROM orders ORDER BY order_date DESC, total_amount ASC;
C. SELECT * FROM orders ORDER BY total_amount DESC, order_date ASC;
D. SELECT * FROM orders ORDER BY total_amount ASC, order_date DESC;
Solution
Step 1: Understand multi-column ORDER BY
ORDER BY can sort by multiple columns in sequence: first column sorts first, then second column breaks ties.
Step 2: Match sorting directions
We want order_date ascending first, then total_amount descending. SELECT * FROM orders ORDER BY order_date ASC, total_amount DESC; matches this order and directions exactly.
Final Answer:
SELECT * FROM orders ORDER BY order_date ASC, total_amount DESC; -> Option A
Quick Check:
First ASC on order_date, then DESC on total_amount [OK]
Hint: List columns in ORDER BY with directions in desired priority [OK]
Common Mistakes:
Swapping column order in ORDER BY
Mixing ASC and DESC directions incorrectly
Using DESC when ASC is needed and vice versa
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.