Oracle Database Quiz Questions

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

The CASE statement in Oracle is used to perform conditional logic in SQL queries.

Q2
True / False

In Oracle, the CASE statement must always include an ELSE clause.

Q3
True / False

The CASE statement in Oracle can be used in both SELECT and UPDATE statements.

Q4
True / False

In Oracle, the CASE statement can only evaluate equality conditions.

Q5
True / False

The CASE statement in Oracle can be nested within another CASE statement.

Q6
True / False

In Oracle, the CASE statement can include aggregate functions within its conditions.

Q7
True / False

In Oracle, the CASE statement can be used in the ORDER BY clause to sort results conditionally.

Q8
True / False

The CASE statement in Oracle can be used to return different data types based on conditions.

Q9
True / False

In Oracle, performance of queries with CASE statements can be optimized using indexes and careful query design.

Q10
True / False

The Oracle Certified Professional (OCP) exam includes knowledge on using the CASE statement effectively, understanding its syntax, and optimizing its performance in SQL queries.

Q11
Single Choice

What is the primary purpose of the CASE statement in ORACLE SQL?

Q12
Single Choice

How many ELSE clauses can you include in a single CASE statement in ORACLE SQL?

Q13
Single Choice

Which keyword is used to end a CASE statement in ORACLE SQL?

Q14
Single Choice

Consider the following Oracle SQL query:What does this query return?

SQL Code
SELECT employee_id,
 CASE
 WHEN salary > 50000 THEN 'High'
 WHEN salary BETWEEN 30000 AND 50000 THEN 'Medium'
 ELSE 'Low'
 END AS salary_level
FROM employees;
Q15
Single Choice

Which of the following ORACLE SQL queries correctly uses the CASE statement to return 'Above Average' for salaries above the average salary and 'Below Average' otherwise?

Q16
Single Choice

Which ORACLE SQL query correctly implements a CASE statement to categorize employees as 'Senior' if their experience is more than 10 years, and 'Junior' otherwise?

Q17
Single Choice

Consider the following Oracle SQL query:What does this query return?

Q18
Single Choice

Which ORACLE SQL query correctly uses the CASE statement to replace NULL values in the salary column with 'Unknown'?

Q19
Single Choice

Which of the following ORACLE SQL queries will calculate a bonus for employees based on the following logic: 10% of the salary for 'Manager' job, 5% of the salary for 'Clerk' job, and 2% for all others?

Q20
Single Choice

Given the following ORACLE SQL query:What does this query do?

Q21
Multiple Choice

Which SQL code snippet demonstrates a basic use of the CASE statement to categorize employees based on their salary in Oracle?

SQL Code
SELECT employee_id, salary,
 CASE
 WHEN salary > 50000 THEN 'High'
 WHEN salary BETWEEN 30000 AND 50000 THEN 'Medium'
 ELSE 'Low'
 END AS salary_category
FROM employees;

SELECT employee_id, salary,
 CASE
 WHEN salary > 60000 THEN 'High'
 WHEN salary BETWEEN 30000 AND 60000 THEN 'Medium'
 ELSE 'Low'
 END AS salary_category
FROM employees;
Q22
Multiple Choice

Which SQL code snippet uses the CASE statement to handle NULL values in Oracle?

SQL Code
SELECT employee_id,
 CASE
 WHEN manager_id IS NULL THEN 'No Manager'
 ELSE manager_id
 END AS manager_status
FROM employees;

SELECT employee_id,
 CASE
 WHEN commission_pct IS NULL THEN 'No Commission'
 ELSE TO_CHAR(commission_pct * 100) || '%'
 END AS commission_status
FROM employees;

SELECT employee_id,
 CASE
 WHEN hire_date IS NULL THEN 'Hire Date Unknown'
 ELSE TO_CHAR(hire_date, 'MM/DD/YYYY')
 END AS hire_date_status
FROM employees;
Q23
Multiple Choice

Which SQL code snippet demonstrates the use of the CASE statement within a GROUP BY clause in Oracle?

SQL Code
SELECT department_id,
 CASE
 WHEN AVG(salary) > 50000 THEN 'High Average Salary'
 ELSE 'Low Average Salary'
 END AS avg_salary_category
FROM employees
GROUP BY department_id;

SELECT department_id,
 CASE
 WHEN COUNT(employee_id) > 10 THEN 'Large Department'
 ELSE 'Small Department'
 END AS department_size
FROM employees
GROUP BY department_id;
Q24
Multiple Choice

Which SQL code snippet uses the CASE statement to create a custom ordering of data in Oracle?

SQL Code
SELECT employee_id, job_title
FROM employees
ORDER BY
 CASE
 WHEN job_title = 'Manager' THEN 1
 WHEN job_title = 'Developer' THEN 2
 ELSE 3
 END;

SELECT department_id, salary
FROM employees
ORDER BY
 CASE
 WHEN salary > 60000 THEN 1
 WHEN salary BETWEEN 40000 AND 60000 THEN 2
 ELSE 3
 END;
Q25
Multiple Choice

Which SQL code snippet demonstrates the use of the CASE statement to apply conditional logic to multiple columns in Oracle?

SQL Code
SELECT employee_id,
 CASE
 WHEN salary > 50000 AND commission_pct IS NOT NULL THEN 'High Salary with Commission'
 WHEN salary > 50000 THEN 'High Salary'
 ELSE 'Standard Salary'
 END AS salary_status
FROM employees;

SELECT employee_id,
 CASE
 WHEN job_title = 'Manager' AND department_id = 10 THEN 'Top Manager'
 WHEN job_title = 'Manager' THEN 'Manager'
 ELSE 'Staff'
 END AS job_status
FROM employees;
Q26
Multiple Choice

Which SQL code snippet demonstrates advanced use of the CASE statement for calculating a new column value based on multiple conditions in Oracle?

SQL Code
SELECT order_id,
 CASE
 WHEN order_total > 1000 AND shipping_cost IS NOT NULL THEN order_total + shipping_cost
 WHEN order_total > 1000 THEN order_total + 50
 ELSE order_total
 END AS final_total
FROM orders;

SELECT order_id,
 CASE
 WHEN customer_type = 'VIP' THEN order_total * 0.9
 WHEN customer_type = 'Regular' THEN order_total * 0.95
 ELSE order_total
 END AS discounted_total
FROM orders;
Q27
Multiple Choice

Which SQL code snippet demonstrates the use of the CASE statement to create a calculated column for a report in Oracle?

SQL Code
SELECT employee_id, salary,
 CASE
 WHEN salary > 50000 THEN salary * 1.1
 ELSE salary * 1.05
 END AS adjusted_salary
FROM employees;

SELECT department_id, salary,
 CASE
 WHEN department_id = 10 THEN salary * 1.2
 ELSE salary * 1.1
 END AS department_adjusted_salary
FROM employees;
Q28
Multiple Choice

Which SQL code snippet demonstrates certification-level use of the CASE statement to apply complex conditional logic to sales data in Oracle?

SQL Code
SELECT sale_id,
 CASE
 WHEN sale_amount > 500 AND sale_date >= SYSDATE - 30 THEN sale_amount * 1.05
 WHEN sale_amount <= 500 AND sale_date < SYSDATE - 30 THEN sale_amount * 1.02
 ELSE sale_amount
 END AS adjusted_sale_amount
FROM sales;

SELECT sale_id,
 CASE
 WHEN region = 'North' AND sale_amount > 1000 THEN sale_amount * 1.1
 WHEN region = 'South' AND sale_amount > 500 THEN sale_amount * 1.05
 ELSE sale_amount
 END AS region_adjusted_sales
FROM sales;
Q29
Multiple Choice

Which SQL code snippet demonstrates the use of the CASE statement to dynamically select different columns based on conditions in Oracle?

SQL Code
SELECT employee_id,
 CASE
 WHEN job_title = 'Manager' THEN department_id
 WHEN job_title = 'Developer' THEN salary
 ELSE hire_date
 END AS dynamic_column
FROM employees;

SELECT employee_id,
 CASE
 WHEN department_id = 10 THEN salary * 1.2
 WHEN department_id = 20 THEN salary * 1.1
 ELSE salary
 END AS adjusted_salary
FROM employees;
Q30
Multiple Choice

Which SQL code snippet demonstrates the use of the CASE statement to create a summary report with conditional logic applied to aggregated data in Oracle?

SQL Code
SELECT department_id, COUNT(employee_id) AS num_employees,
 CASE
 WHEN AVG(salary) > 60000 THEN 'High Average Salary'
 ELSE 'Moderate Average Salary'
 END AS salary_status
FROM employees
GROUP BY department_id;

SELECT region, SUM(sales_amount) AS total_sales,
 CASE
 WHEN SUM(sales_amount) > 100000 THEN 'High Revenue Region'
 ELSE 'Moderate Revenue Region'
 END AS revenue_status
FROM sales
GROUP BY region;