MySQL Database Quiz Questions

Course Name:MySQL
Chapter Name:Chapter 7 - DQL (Data Query Language)
Lesson Content Link:ORDER BY
Current Quiz Count:30
Progress
0%
Q1
True / False

In MySQL, the ORDER BY clause is used to sort the result set in ascending or descending order.

Q2
True / False

By default, MySQL sorts results in descending order when using the ORDER BY clause.

Q3
True / False

MySQL allows sorting by multiple columns in the ORDER BY clause.

Q4
True / False

In MySQL, when using ORDER BY, you can only sort by columns that are part of the SELECT statement.

Q5
True / False

MySQL's ORDER BY clause can be used with aggregate functions such as COUNT and SUM.

Q6
True / False

In MySQL, ORDER BY can be used with the LIMIT clause to fetch the top N rows in a sorted order.

Q7
True / False

MySQL does not support sorting by expressions or calculated columns in the ORDER BY clause.

Q8
True / False

When sorting by multiple columns in MySQL, the secondary sort column can have a different sort direction than the primary sort column.

Q9
True / False

MySQL uses a stable sort algorithm to maintain the relative order of rows with equal sort keys.

Q10
True / False

In MySQL, using ORDER BY with a BLOB or TEXT column requires specifying the COLLATE clause to define the collation explicitly.

Q11
Single Choice

Which of the following keywords can be used with MySQL's ORDER BY clause to sort the results in descending order?

Q12
Single Choice

What is the default sorting order when you use the ORDER BY clause in MySQL without specifying ASC or DESC?

Q13
Single Choice

Given the SQL query: SELECT name FROM employees ORDER BY salary;, how will the results be sorted?

Q14
Single Choice

Consider the following SQL query: SELECT product_name, price FROM products ORDER BY price DESC, product_name ASC;. What will be the primary sorting criterion?

Q15
Single Choice

What will be the result of executing the following query? SELECT name, age FROM students ORDER BY 2 ASC;

Q16
Single Choice

Given the query SELECT id, score FROM results ORDER BY score DESC LIMIT 5;, what does the LIMIT clause achieve?

Q17
Single Choice

Consider the query SELECT name, salary FROM employees WHERE salary > 50000 ORDER BY salary DESC, name ASC;. What will be the order of the result set?

Q18
Single Choice

What will be the outcome of the query SELECT * FROM orders ORDER BY order_date IS NULL, order_date ASC;?

Q19
Single Choice

In MySQL, how does the ORDER BY clause behave when used with the UNION operator as in SELECT id, name FROM table1 UNION SELECT id, name FROM table2 ORDER BY name;?

Q20
Single Choice

Given the query SELECT department, COUNT(*) AS num_employees FROM employees GROUP BY department ORDER BY num_employees DESC, department ASC;, what will be the order of the result set?

Q21
Multiple Choice

Which query correctly sorts the 'employees' table by 'salary' in ascending order?

SQL Code
SELECT *
FROM employees
ORDER BY salary ASC;
Q22
Multiple Choice

Identify the correct SQL query that sorts the 'products' table by 'price' in descending order.

SQL Code
SELECT *
FROM products
ORDER BY price DESC;
Q23
Multiple Choice

Which query sorts the 'orders' table first by 'order_date' in ascending order and then by 'total_amount' in descending order?

SQL Code
SELECT *
FROM orders
ORDER BY order_date ASC, total_amount DESC;
Q24
Multiple Choice

Determine the correct SQL query that retrieves all rows from the 'customers' table sorted by 'city' in alphabetical order.

SQL Code
SELECT *
FROM customers
ORDER BY city ASC;
Q25
Multiple Choice

Which query retrieves the 'inventory' table sorted by 'category' in ascending order and by 'stock' in descending order?

SQL Code
SELECT *
FROM inventory
ORDER BY category ASC, stock DESC;
Q26
Multiple Choice

Identify the correct query that sorts the 'employees' table by 'department' in ascending order and by 'hire_date' in descending order.

SQL Code
SELECT *
FROM employees
ORDER BY department ASC, hire_date DESC;
Q27
Multiple Choice

Which query correctly sorts the 'sales' table by 'region' in alphabetical order and by 'sales_amount' in ascending order?

SQL Code
SELECT *
FROM sales
ORDER BY region ASC, sales_amount ASC;
Q28
Multiple Choice

Determine the correct SQL query that retrieves all rows from 'products' table sorted by 'category' and then by 'price' in descending order.

SQL Code
SELECT *
FROM products
ORDER BY category, price DESC;
Q29
Multiple Choice

Which query retrieves the 'projects' table sorted by 'start_date' in ascending order and 'end_date' in descending order?

SQL Code
SELECT *
FROM projects
ORDER BY start_date ASC, end_date DESC;
Q30
Multiple Choice

Identify the correct SQL query that retrieves distinct 'employee_id' and 'hire_date' values from the 'employees' table, sorted by 'hire_date' in descending order.

SQL Code
SELECT DISTINCT employee_id, hire_date
FROM employees
ORDER BY hire_date DESC;