0
0
MySQLquery~10 mins

ORDER BY multiple columns 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 order 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'
Aage
Bname
Csalary
Did
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 order the results by 'age' ascending and then by 'name' ascending.

MySQL
SELECT * FROM users ORDER BY [1], name;
Drag options to blanks, or click blank then click option'
Aage
Bsalary
Cid
Ddate_joined
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the order of columns.
Using a wrong column name.
3fill in blank
hard

Fix the error in the code to order by 'age' ascending and 'name' descending.

MySQL
SELECT * FROM users ORDER BY age, [1] DESC;
Drag options to blanks, or click blank then click option'
Asalary
Bid
Cname
Dage
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong column name.
Placing DESC before the column name.
4fill in blank
hard

Fill both blanks to order by 'department' ascending and 'salary' descending.

MySQL
SELECT * FROM employees ORDER BY [1], [2] DESC;
Drag options to blanks, or click blank then click option'
Adepartment
Bage
Csalary
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the order of columns.
Forgetting DESC for the second column.
5fill in blank
hard

Fill all three blanks to order by 'country' ascending, 'city' ascending, and 'population' descending.

MySQL
SELECT * FROM locations ORDER BY [1], [2], [3] DESC;
Drag options to blanks, or click blank then click option'
Acountry
Bcity
Cpopulation
Darea
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing the order of columns.
Forgetting DESC for the last column.