0
0
SQLquery~10 mins

ORDER BY with ASC and DESC 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 salary in ascending order.

SQL
SELECT * FROM employees ORDER BY salary [1];
Drag options to blanks, or click blank then click option'
AASC
BDESC
CBY
DFROM
Attempts:
3 left
💡 Hint
Common Mistakes
Using DESC instead of ASC for ascending order.
Omitting ORDER BY clause.
2fill in blank
medium

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

SQL
SELECT * FROM products ORDER BY price [1];
Drag options to blanks, or click blank then click option'
AASC
BDESC
CGROUP BY
DHAVING
Attempts:
3 left
💡 Hint
Common Mistakes
Using ASC instead of DESC for descending order.
Confusing ORDER BY with GROUP BY.
3fill in blank
hard

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

SQL
SELECT * FROM customers ORDER BY last_name [1];
Drag options to blanks, or click blank then click option'
AORDER
BDESC
CASC
DBY
Attempts:
3 left
💡 Hint
Common Mistakes
Using DESC when ascending order is needed.
Omitting ASC or DESC (defaults to ASC but explicit is clearer).
4fill in blank
hard

Fill both blanks to sort the orders by order_date descending and then by customer_id ascending.

SQL
SELECT * FROM orders ORDER BY order_date [1], customer_id [2];
Drag options to blanks, or click blank then click option'
ADESC
BASC
CBY
DFROM
Attempts:
3 left
💡 Hint
Common Mistakes
Using ASC for both columns.
Mixing up the order of ASC and DESC.
5fill in blank
hard

Fill all three blanks to sort the employees by department ascending, then salary descending, then hire_date ascending.

SQL
SELECT * FROM employees ORDER BY department [1], salary [2], hire_date [3];
Drag options to blanks, or click blank then click option'
AASC
BDESC
Attempts:
3 left
💡 Hint
Common Mistakes
Using DESC for department or hire_date.
Using ASC for salary instead of DESC.