Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
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.
✗ Incorrect
The
ORDER BY clause sorts the results by the specified column. Here, sorting by age orders the rows by age in ascending order.2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using ascending order by mistake when descending is needed.
Choosing the wrong column to sort by.
✗ Incorrect
Adding
DESC after the column name sorts the results in descending order by that column. Here, sorting by price descending shows the most expensive products first.3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Ordering by first name instead of last name.
Using a column that does not exist.
✗ Incorrect
The query must order by the
last_name column to meet the requirement. Using last_name correctly sorts employees by their last names.4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
DESC instead of ASC.Choosing the wrong column to sort by.
✗ Incorrect
The query orders the results by
order_date in ascending order. The first blank is the column name, and the second blank is the sorting direction ASC.5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using ascending order instead of descending.
Mixing up table and column names.
✗ Incorrect
The query selects all rows from the
students table and orders them by the grade column in descending order. The blanks correspond to the table name, column name, and sorting order.