0
0
SQLquery~10 mins

ORDER BY single column in SQL - 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 employees by their age in ascending order.

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

Complete the code to list products sorted by their price from lowest to highest.

SQL
SELECT product_name, price FROM products ORDER BY [1];
Drag options to blanks, or click blank then click option'
Aprice
Bcategory
Cproduct_name
Dstock
Attempts:
3 left
💡 Hint
Common Mistakes
Sorting by product name instead of price.
Using a column not related to price.
3fill in blank
hard

Fix the error in the query to sort customers by their last name.

SQL
SELECT * FROM customers ORDER BY [1];
Drag options to blanks, or click blank then click option'
Aemail
Blastname
Cfirstname
Dphone
Attempts:
3 left
💡 Hint
Common Mistakes
Using firstname instead of lastname.
Misspelling the column name.
4fill in blank
hard

Fill both blanks to select all orders and sort them by order date in descending order.

SQL
SELECT * FROM orders ORDER BY [1] [2];
Drag options to blanks, or click blank then click option'
Aorder_date
BASC
CDESC
Dcustomer_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using ascending order instead of descending.
Sorting by wrong column.
5fill in blank
hard

Fill all three blanks to select product names and prices, sorting by price ascending.

SQL
SELECT [1], [2] FROM products ORDER BY [3];
Drag options to blanks, or click blank then click option'
Aproduct_name
Bprice
Dcategory
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting wrong columns.
Sorting by a column not selected.