0
0
SQLquery~10 mins

Why ordering matters in SQL - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to select all columns from the table ordered by the column 'age' in ascending order.

SQL
SELECT * FROM users ORDER BY [1];
Drag options to blanks, or click blank then click option'
Aname
Bsalary
Cage
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a column that does not exist or is unrelated to sorting by age.
Forgetting to use ORDER BY clause.
2fill in blank
medium

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

SQL
SELECT * FROM employees ORDER BY [1] DESC;
Drag options to blanks, or click blank then click option'
Aname
Bage
Cdepartment
Dsalary
Attempts:
3 left
💡 Hint
Common Mistakes
Using ascending order when descending is required.
Choosing a wrong column like 'age' or 'name'.
3fill in blank
hard

Fix the error in the query to order by 'date_joined' ascending.

SQL
SELECT * FROM members ORDER BY [1] ASC;
Drag options to blanks, or click blank then click option'
Adate_joined
Bdatejoined
Cjoined_date
Djoin_date
Attempts:
3 left
💡 Hint
Common Mistakes
Using a similar but incorrect column name.
Misspelling the column name or missing underscores.
4fill in blank
hard

Fill both blanks to order the products by 'category' ascending and then by 'price' descending.

SQL
SELECT * FROM products ORDER BY [1] [2], price DESC;
Drag options to blanks, or click blank then click option'
Acategory
BASC
CDESC
Dprice
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up ascending and descending orders.
Using the wrong column name for the first order.
5fill in blank
hard

Fill all three blanks to order the sales records by 'region' ascending, then 'sales_date' descending, and finally by 'amount' ascending.

SQL
SELECT * FROM sales ORDER BY [1] [2], [3] DESC, amount ASC;
Drag options to blanks, or click blank then click option'
Aregion
BASC
Csales_date
DDESC
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping ascending and descending orders.
Using wrong column names or order directions.