Microsoft SQL Server Database Quiz Questions

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

The ORDER BY clause is used to sort the result set in ascending order by default.

SQL Code
SELECT *
FROM Employees
ORDER BY EmployeeID;
Q2
True / False

You can use multiple columns in the ORDER BY clause to sort the result set.

SQL Code
SELECT *
FROM Employees
ORDER BY DepartmentID, EmployeeID;
Q3
True / False

The ORDER BY clause can only be used in SELECT statements.

SQL Code
SELECT *
FROM Employees
ORDER BY EmployeeID;
Q4
True / False

The ORDER BY clause must be the last clause in the SELECT statement.

SQL Code
SELECT *
FROM Employees
WHERE DepartmentID = 3
ORDER BY EmployeeID;
Q5
True / False

You can use the ORDER BY clause in conjunction with the DISTINCT keyword.

SQL Code
SELECT DISTINCT DepartmentID
FROM Employees
ORDER BY DepartmentID;
Q6
True / False

The ORDER BY clause can sort the result set in descending order using the DESC keyword.

SQL Code
SELECT *
FROM Employees
ORDER BY EmployeeID DESC;
Q7
True / False

You can sort the result set by columns that are not included in the SELECT statement.

SQL Code
SELECT EmployeeName
FROM Employees
ORDER BY EmployeeID;
Q8
True / False

The ORDER BY clause can use expressions to determine the sorting order.

SQL Code
SELECT *
FROM Employees
ORDER BY LEN(EmployeeName);
Q9
True / False

The ORDER BY clause can sort the result set by alias names.

SQL Code
SELECT EmployeeName AS Name
FROM Employees
ORDER BY Name;
Q10
True / False

The ORDER BY clause can use the column index to sort the result set.

SQL Code
SELECT EmployeeID, EmployeeName
FROM Employees
ORDER BY 2;
Q11
True / False

The ORDER BY clause is case-insensitive when sorting text data.

SQL Code
SELECT *
FROM Employees
ORDER BY EmployeeName;
Q12
True / False

You can use the COLLATE keyword with ORDER BY to perform case-sensitive sorting.

SQL Code
SELECT *
FROM Employees
ORDER BY EmployeeName COLLATE Latin1_General_BIN;
Q13
True / False

ORDER BY can sort the result set based on the result of a subquery.

SQL Code
SELECT *
FROM (SELECT * FROM Employees) AS Subquery
ORDER BY EmployeeID;
Q14
True / False

ORDER BY can be used in a UNION query to sort the combined result set.

SQL Code
SELECT EmployeeID
FROM Employees
UNION
SELECT DepartmentID
FROM Departments
ORDER BY EmployeeID;
Q15
True / False

The ORDER BY clause can be used with the OVER() clause to provide a custom sort order within a window function.

SQL Code
SELECT EmployeeID,
RANK() OVER (ORDER BY Salary DESC) AS SalaryRank
FROM Employees;
Q16
Single Choice

Which keyword is used with ORDER BY to sort the result set in descending order?

SQL Code
SELECT *
FROM Employees
ORDER BY EmployeeID ____;
Q17
Single Choice

How do you sort the result set by the length of the EmployeeName column?

SQL Code
SELECT *
FROM Employees
ORDER BY ____(EmployeeName);
Q18
Single Choice

Which clause should be used to sort the result set by alias names?

SQL Code
SELECT EmployeeName AS Name
FROM Employees
ORDER BY ____;
Q19
Single Choice

Which of the following queries correctly sorts the result set by the EmployeeID column in ascending order?

SQL Code
SELECT *
FROM Employees
____ EmployeeID ASC;
Q20
Single Choice

How can you sort the result set by the length of the EmployeeName in descending order?

SQL Code
SELECT *
FROM Employees
ORDER BY LEN(EmployeeName) ____;
Q21
Single Choice

What is the result of the following query?

SQL Code
SELECT *
FROM Employees
ORDER BY EmployeeName COLLATE Latin1_General_BIN;
Q22
Single Choice

Which of the following queries sorts the result set by the DepartmentID column in descending order?

SQL Code
SELECT *
FROM Employees
ORDER BY ____ DESC;
Q23
Single Choice

Which of the following queries correctly sorts the result set by the EmployeeName column in ascending order?

SQL Code
SELECT *
FROM Employees
ORDER BY ____ ASC;
Q24
Single Choice

Which of the following clauses is used to sort the result set?

SQL Code
SELECT *
FROM Employees
____ EmployeeID ASC;
Q25
Single Choice

Which of the following queries sorts the result set by the EmployeeID column in ascending order and by EmployeeName in descending order?

SQL Code
SELECT *
FROM Employees
ORDER BY EmployeeID ASC, EmployeeName DESC;
Q26
Single Choice

Which of the following queries correctly sorts the result set by EmployeeName in descending order?

SQL Code
SELECT *
FROM Employees
ORDER BY EmployeeName ____;
Q27
Single Choice

How do you sort the result set by EmployeeID and then by EmployeeName?

SQL Code
SELECT *
FROM Employees
ORDER BY EmployeeID, ____;
Q28
Single Choice

Which of the following queries sorts the result set by the EmployeeAge column in ascending order?

SQL Code
SELECT *
FROM Employees
ORDER BY ____ ASC;
Q29
Single Choice

Which of the following queries correctly sorts the result set by the Salary column in descending order?

SQL Code
SELECT *
FROM Employees
ORDER BY Salary ____;
Q30
Single Choice

Which of the following queries sorts the result set by the DepartmentID column in descending order?

SQL Code
SELECT *
FROM Employees
ORDER BY ____ DESC;
Q31
Multiple Choice

Which of the following queries correctly sorts the result set by EmployeeName and EmployeeID?

SQL Code
SELECT *
FROM Employees
ORDER BY ____;
Q32
Multiple Choice

How can you sort the result set by the length of EmployeeName and then by EmployeeID?

SQL Code
SELECT *
FROM Employees
ORDER BY LEN(EmployeeName), ____;
Q33
Multiple Choice

Which of the following clauses can be used to sort the result set?

SQL Code
SELECT *
FROM Employees
ORDER BY ____ ASC;
Q34
Multiple Choice

How do you sort the result set by EmployeeID in ascending order and by EmployeeName in descending order?

SQL Code
SELECT *
FROM Employees
ORDER BY EmployeeID ASC, ____ DESC;
Q35
Multiple Choice

Which of the following queries sorts the result set by EmployeeName in descending order?

SQL Code
SELECT *
FROM Employees
ORDER BY EmployeeName ____;
Q36
Multiple Choice

Which of the following queries sorts the result set by the length of EmployeeName?

SQL Code
SELECT *
FROM Employees
ORDER BY ____;
Q37
Multiple Choice

Which of the following queries correctly sorts the result set by DepartmentID in descending order?

SQL Code
SELECT *
FROM Employees
ORDER BY ____ DESC;
Q38
Multiple Choice

Which of the following queries sorts the result set by EmployeeAge in ascending order?

SQL Code
SELECT *
FROM Employees
ORDER BY ____ ASC;
Q39
Multiple Choice

Which of the following queries correctly sorts the result set by Salary in descending order?

SQL Code
SELECT *
FROM Employees
ORDER BY Salary ____;
Q40
Multiple Choice

Which of the following queries sorts the result set by DepartmentID in ascending order?

SQL Code
SELECT *
FROM Employees
ORDER BY ____ ASC;
Q41
Multiple Choice

How do you sort the result set by EmployeeID and EmployeeName?

SQL Code
SELECT *
FROM Employees
ORDER BY EmployeeID, ____;
Q42
Multiple Choice

Which of the following queries correctly sorts the result set by EmployeeName in ascending order?

SQL Code
SELECT *
FROM Employees
ORDER BY ____ ASC;
Q43
Multiple Choice

Which of the following queries sorts the result set by DepartmentID in descending order and EmployeeName in ascending order?

SQL Code
SELECT *
FROM Employees
ORDER BY DepartmentID DESC, ____ ASC;
Q44
Multiple Choice

Which of the following queries sorts the result set by EmployeeAge in descending order and Salary in ascending order?

SQL Code
SELECT *
FROM Employees
ORDER BY EmployeeAge DESC, ____ ASC;
Q45
Multiple Choice

Which of the following clauses can be used to sort the result set by EmployeeName?

SQL Code
SELECT *
FROM Employees
ORDER BY ____ ASC;