Oracle Database Quiz Questions

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

In Oracle, the RANK function is used to assign a rank to each row within a partition of a result set.

Q2
True / False

The DENSE_RANK function in Oracle assigns unique ranks without gaps between the ranks.

Q3
True / False

In Oracle, the RANK function can be used without the OVER clause.

Q4
True / False

In Oracle, you can use the RANK function to rank rows within each group created by the GROUP BY clause.

Q5
True / False

The RANK function in Oracle assigns the same rank to rows with equal values, but leaves gaps in the ranking sequence.

Q6
True / False

In Oracle, the NTILE function can be used to divide rows into a specified number of roughly equal groups.

Q7
True / False

In Oracle, the RANK function can be used in a WHERE clause to filter rows based on their rank.

Q8
True / False

The ROW_NUMBER function in Oracle assigns a unique sequential integer to rows within a partition, without regard to ties.

Q9
True / False

In Oracle, you can use window functions like RANK and DENSE_RANK in combination with analytic functions to perform complex calculations over partitions of data.

Q10
True / False

The Oracle Certified Professional (OCP) exam includes knowledge on using ranking functions like RANK, DENSE_RANK, and ROW_NUMBER effectively, understanding their syntax, and optimizing their performance in SQL queries.

Q11
Single Choice

Which Oracle SQL function is used to assign a unique rank to each distinct value in a result set, based on the ordering of a specified column?

Q12
Single Choice

In Oracle, which of the following functions is most suitable to rank rows within a group and allows for ranking with gaps?

Q13
Single Choice

What is the correct syntax for using the RANK function in Oracle to rank rows based on the salary column?

Q14
Single Choice

Which Oracle SQL function can be used in conjunction with PARTITION BY to rank rows within each group?

Q15
Single Choice

Consider the following Oracle SQL query:What does the query achieve?

SQL Code
SELECT employee_id, department_id,
 RANK() OVER (PARTITION BY department_id ORDER BY salary DESC) AS emp_rank
FROM employees;
Q16
Single Choice

Given the Oracle SQL code:Which employees will have the same rank within a department?

SQL Code
SELECT employee_id, department_id,
 RANK() OVER (PARTITION BY department_id ORDER BY hire_date) AS hire_rank
FROM employees;
Q17
Single Choice

Consider the Oracle SQL query:What is the difference between salary_rank and dense_salary_rank?

SQL Code
SELECT employee_id,
 RANK() OVER (ORDER BY salary DESC) AS salary_rank,
 DENSE_RANK() OVER (ORDER BY salary DESC) AS dense_salary_rank
FROM employees;
Q18
Single Choice

In Oracle SQL, which ranking function should be used if you want to ensure that no gaps appear in the rank sequence even when there are ties?

Q19
Single Choice

Which of the following Oracle SQL statements correctly ranks employees within departments by salary, ensuring no gaps in ranking?

Q20
Single Choice

You have a dataset in an Oracle database where you want to assign ranks to employees based on their salary, but you want to ensure that employees with the same salary receive the same rank, and that there are no gaps in the rank sequence. Which SQL query achieves this?

Q21
Multiple Choice

Which SQL code snippet demonstrates using the `RANK` function to assign ranks within a department based on salary?

SQL Code
SELECT employee_id, department_id, salary,
RANK() OVER (PARTITION BY department_id ORDER BY salary DESC) AS salary_rank
FROM employees;
Q22
Multiple Choice

Which SQL code snippet demonstrates using the `DENSE_RANK` function to handle ranking when duplicate values exist?

SQL Code
SELECT employee_id, department_id, salary,
DENSE_RANK() OVER (PARTITION BY department_id ORDER BY salary DESC) AS salary_dense_rank
FROM employees;
Q23
Multiple Choice

Which SQL code snippet demonstrates using the `ROW_NUMBER` function to assign unique row numbers within each department?

SQL Code
SELECT employee_id, department_id, salary,
ROW_NUMBER() OVER (PARTITION BY department_id ORDER BY salary DESC) AS row_num
FROM employees;
Q24
Multiple Choice

Which SQL code snippet demonstrates using `RANK` in conjunction with `GROUP BY` to rank departments by their average salary?

SQL Code
SELECT department_id, AVG(salary) AS avg_salary,
RANK() OVER (ORDER BY AVG(salary) DESC) AS dept_rank
FROM employees
GROUP BY department_id;
Q25
Multiple Choice

Which SQL code snippet demonstrates using `NTILE` to divide employees into quartiles based on their salary?

SQL Code
SELECT employee_id, salary,
NTILE(4) OVER (ORDER BY salary DESC) AS salary_quartile
FROM employees;
Q26
Multiple Choice

Which SQL code snippet demonstrates advanced use of the `RANK` function to rank employees within each department based on their performance score?

SQL Code
SELECT employee_id, department_id, performance_score,
RANK() OVER (PARTITION BY department_id ORDER BY performance_score DESC) AS performance_rank
FROM employees;
Q27
Multiple Choice

Which SQL code snippet demonstrates advanced use of the `DENSE_RANK` function in a nested subquery to rank employees by hire date within their department?

SQL Code
SELECT employee_id, department_id, hire_date
FROM (SELECT employee_id, department_id, hire_date,
DENSE_RANK() OVER (PARTITION BY department_id ORDER BY hire_date) AS hire_rank
FROM employees) subquery
WHERE hire_rank = 1;
Q28
Multiple Choice

Which SQL code snippet demonstrates certification-level use of the `RANK` function to determine the top 3 highest-paid employees in each department?

SQL Code
SELECT employee_id, department_id, salary
FROM (SELECT employee_id, department_id, salary,
RANK() OVER (PARTITION BY department_id ORDER BY salary DESC) AS salary_rank
FROM employees) subquery
WHERE salary_rank <= 3;
Q29
Multiple Choice

Which SQL code snippet demonstrates certification-level use of the `RANK` function combined with a window function to calculate cumulative salary?

SQL Code
SELECT employee_id, department_id, salary,
SUM(salary) OVER (ORDER BY RANK() OVER (PARTITION BY department_id ORDER BY salary DESC)) AS cumulative_salary
FROM employees;
Q30
Multiple Choice

Which SQL code snippet demonstrates certification-level use of the `DENSE_RANK` function to identify the highest-performing department?

SQL Code
SELECT department_id, performance_score,
DENSE_RANK() OVER (ORDER BY AVG(performance_score) DESC) AS dept_rank
FROM employees
GROUP BY department_id
HAVING DENSE_RANK() = 1;