0
0
MySQLquery~10 mins

ORDER BY single column in MySQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to sort the results by the column age in ascending order.

MySQL
SELECT * FROM users ORDER BY [1];
Drag options to blanks, or click blank then click option'
Aid
Bname
Csalary
Dage
Attempts:
3 left
💡 Hint
Common Mistakes
Using a column name that does not exist in the table.
Forgetting to specify the column after ORDER BY.
2fill in blank
medium

Complete the code to sort the products table by price in descending order.

MySQL
SELECT * FROM products ORDER BY [1] DESC;
Drag options to blanks, or click blank then click option'
Aprice
Bname
Ccategory
Dstock
Attempts:
3 left
💡 Hint
Common Mistakes
Using ascending order by mistake when descending is needed.
Choosing the wrong column to sort by.
3fill in blank
hard

Fix the error in the query to sort employees by last_name in ascending order.

MySQL
SELECT * FROM employees ORDER BY [1] ASC;
Drag options to blanks, or click blank then click option'
Aemployee_id
Bdepartment
Clast_name
Dfirst_name
Attempts:
3 left
💡 Hint
Common Mistakes
Ordering by first name instead of last name.
Using a column that does not exist.
4fill in blank
hard

Fill both blanks to select all from orders and sort by order_date in ascending order.

MySQL
SELECT * FROM orders ORDER BY [1] [2];
Drag options to blanks, or click blank then click option'
Aorder_date
BDESC
CASC
Dcustomer_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using DESC instead of ASC.
Choosing the wrong column to sort by.
5fill in blank
hard

Fill all three blanks to select all from students and sort by grade descending.

MySQL
SELECT * FROM [1] ORDER BY [2] [3];
Drag options to blanks, or click blank then click option'
Astudents
Bgrade
CDESC
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using ascending order instead of descending.
Mixing up table and column names.