0
0
SQLquery~10 mins

ORDER BY multiple columns 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 results by the column 'age'.

SQL
SELECT * FROM employees ORDER BY [1];
Drag options to blanks, or click blank then click option'
Asalary
Bname
Cage
Ddepartment
Attempts:
3 left
💡 Hint
Common Mistakes
Using a column name not in the table.
Forgetting to specify the column after ORDER BY.
2fill in blank
medium

Complete the code to sort the results by 'department' first, then by 'salary'.

SQL
SELECT * FROM employees ORDER BY [1], salary;
Drag options to blanks, or click blank then click option'
Aage
Bposition
Cname
Ddepartment
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the order of columns in ORDER BY.
Using a column not in the table.
3fill in blank
hard

Fix the error in the code to correctly order by 'department' ascending and 'salary' descending.

SQL
SELECT * FROM employees ORDER BY department, salary [1];
Drag options to blanks, or click blank then click option'
AASC
BDESC
CDOWN
DUP
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid keywords like UP or DOWN.
Omitting ASC or DESC when needed.
4fill in blank
hard

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

SQL
SELECT * FROM employees ORDER BY department [1], salary [2];
Drag options to blanks, or click blank then click option'
AASC
BDESC
CUP
DDOWN
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid keywords like UP or DOWN.
Mixing the order of ASC and DESC.
5fill in blank
hard

Fill all three blanks to order by 'department' ascending, 'salary' descending, and 'age' ascending.

SQL
SELECT * FROM employees ORDER BY [1] [2], salary [3], age;
Drag options to blanks, or click blank then click option'
Adepartment
BDESC
CASC
Dage
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing column names and order keywords.
Using wrong order keywords like UP or DOWN.