PostgreSQL Database Quiz Questions

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

In PostgreSQL, the ORDER BY clause is used to sort the result set.

Q2
True / False

In PostgreSQL, the ORDER BY clause sorts the result set in ascending order by default.

Q3
True / False

In PostgreSQL, the ORDER BY clause must always be used with the LIMIT clause.

Q4
True / False

In PostgreSQL, the ORDER BY clause can sort the result set by multiple columns.

Q5
True / False

In PostgreSQL, the ORDER BY clause can use column aliases defined in the SELECT statement.

Q6
True / False

In PostgreSQL, you cannot use ORDER BY with expressions or functions.

Q7
True / False

In PostgreSQL, using ORDER BY with a large dataset can impact query performance.

Q8
True / False

In PostgreSQL, the ORDER BY clause can sort null values first or last by using NULLS FIRST or NULLS LAST.

Q9
True / False

In PostgreSQL, the ORDER BY clause can be used in subqueries and window functions.

Q10
True / False

In PostgreSQL, using the ORDER BY clause with DISTINCT in a query requires the columns in ORDER BY to be included in the DISTINCT clause.

Q11
Single Choice

Which keyword is used to sort the result set in ascending order by default in PostgreSQL?

Q12
Single Choice

What is the default sorting order when using the ORDER BY clause in PostgreSQL?

Q13
Single Choice

How do you sort the result set by multiple columns in PostgreSQL?

Q14
Single Choice

Given the table employees(name TEXT, salary INTEGER), which query will return the list of employees sorted by salary in descending order?

Q15
Single Choice

How would you modify the following query to also sort by name in ascending order when salaries are equal?

SQL Code
SELECT name, salary FROM employees ORDER BY salary DESC;
Q16
Single Choice

What will be the output order of the following query?

SQL Code
SELECT name, age FROM students ORDER BY 2 DESC;
Q17
Single Choice

Given the table products(name TEXT, category TEXT, price NUMERIC), which query will return all products sorted first by category in ascending order, and then by price in descending order?

Q18
Single Choice

In PostgreSQL, which query will sort the employees table by salary in ascending order and display only the top 5 highest salaries?

SQL Code
SELECT * FROM employees ORDER BY salary ASC LIMIT 5;
Q19
Single Choice

How do you ensure that NULL values appear at the end of the result set when using ORDER BY in PostgreSQL?

SQL Code
SELECT name, salary FROM employees ORDER BY salary;
Q20
Single Choice

Which of the following queries correctly orders a list of products by price in descending order, but only for those products in the 'Electronics' category, with any NULL prices appearing last?

Q21
Multiple Choice

Identify the SQL scripts that correctly perform a basic ORDER BY operation in PostgreSQL.

Q22
Multiple Choice

Select the SQL scripts that correctly perform an ORDER BY operation on multiple columns in PostgreSQL.

Q23
Multiple Choice

Determine the SQL scripts that correctly perform an ORDER BY operation with NULLS FIRST in PostgreSQL.

Q24
Multiple Choice

Identify the SQL scripts that correctly perform an ORDER BY operation with LIMIT in PostgreSQL.

Q25
Multiple Choice

Select the SQL scripts that correctly perform an ORDER BY operation with JOINs in PostgreSQL.

Q26
Multiple Choice

Determine the SQL scripts that correctly perform an ORDER BY operation with window functions in PostgreSQL.

Q27
Multiple Choice

Identify the SQL scripts that correctly perform an ORDER BY operation with GROUP BY in PostgreSQL.

Q28
Multiple Choice

Select the SQL scripts that correctly perform an ORDER BY operation with DISTINCT in PostgreSQL.

Q29
Multiple Choice

Determine the SQL scripts that correctly perform an ORDER BY operation with OFFSET in PostgreSQL.

Q30
Multiple Choice

Identify the SQL scripts that correctly perform an ORDER BY operation with UNION in PostgreSQL.