0
0
SQLquery~10 mins

ORDER BY with NULL values behavior 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 order the results by the column 'age' in ascending order.

SQL
SELECT * FROM users ORDER BY [1];
Drag options to blanks, or click blank then click option'
Asalary
Bname
Cid
Dage
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a column unrelated to the sorting requirement.
Forgetting to specify the column name.
2fill in blank
medium

Complete the code to order the results by 'score' in descending order.

SQL
SELECT * FROM results ORDER BY [1] DESC;
Drag options to blanks, or click blank then click option'
Ascore
Bdate
Cplayer
Dlevel
Attempts:
3 left
💡 Hint
Common Mistakes
Using ascending order instead of descending.
Choosing the wrong column for sorting.
3fill in blank
hard

Fix the error in the code to order by 'salary' in ascending order with NULL values appearing last.

SQL
SELECT * FROM employees ORDER BY salary [1] NULLS LAST;
Drag options to blanks, or click blank then click option'
ADESC
BASC
CSORT
DORDER
Attempts:
3 left
💡 Hint
Common Mistakes
Using DESC instead of ASC.
Using invalid keywords like SORT or ORDER in this position.
4fill in blank
hard

Fill both blanks to order by 'date' descending and place NULL values first.

SQL
SELECT * FROM events ORDER BY date [1] NULLS [2];
Drag options to blanks, or click blank then click option'
ADESC
BASC
CFIRST
DLAST
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing ASC with NULLS FIRST incorrectly.
Using NULLS LAST when NULLS FIRST is needed.
5fill in blank
hard

Fill all three blanks to order by 'rating' ascending, place NULLs last, and then by 'name' ascending.

SQL
SELECT * FROM products ORDER BY rating [1] NULLS [2], name [3];
Drag options to blanks, or click blank then click option'
ADESC
BASC
CLAST
DFIRST
Attempts:
3 left
💡 Hint
Common Mistakes
Using DESC instead of ASC for ascending order.
Using NULLS FIRST instead of NULLS LAST.
Forgetting to specify order for the second column.