Oracle Database Quiz Questions

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

The HAVING clause in Oracle is used to filter groups of rows created by the GROUP BY clause.

Q2
True / False

The HAVING clause can be used without a GROUP BY clause in Oracle.

Q3
True / False

In Oracle, the HAVING clause must follow the GROUP BY clause in a query.

Q4
True / False

In Oracle, the HAVING clause can include aggregate functions like SUM, COUNT, AVG, MIN, and MAX.

Q5
True / False

The HAVING clause in Oracle can be combined with the WHERE clause in the same query.

Q6
True / False

In Oracle, you can use column aliases defined in the SELECT clause within the HAVING clause.

Q7
True / False

The HAVING clause in Oracle can be used with logical operators like AND and OR to form complex conditions.

Q8
True / False

In Oracle, the HAVING clause can be used in subqueries to filter groups in the subquery results.

Q9
True / False

Using the HAVING clause instead of the WHERE clause in Oracle can improve query performance.

Q10
True / False

The Oracle Certified Professional (OCP) exam includes knowledge on using the HAVING clause effectively, optimizing its performance, and understanding its interaction with the GROUP BY clause and aggregate functions.

Q11
Single Choice

What is the primary purpose of the HAVING clause in ORACLE SQL?

Q12
Single Choice

Which clause is typically used with the HAVING clause in an ORACLE SQL query?

Q13
Single Choice

What is the difference between the WHERE clause and the HAVING clause in ORACLE SQL?

Q14
Single Choice

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

SQL Code
SELECT department_id, COUNT(*)
FROM employees
GROUP BY department_id
HAVING COUNT(*) > 5;
Q15
Single Choice

Which of the following ORACLE SQL queries will correctly return the sum of salaries for departments having more than 10 employees?

Q16
Single Choice

Which statement best describes the usage of HAVING with multiple conditions in ORACLE SQL?

Q17
Single Choice

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

SQL Code
SELECT department_id, AVG(salary)
FROM employees
GROUP BY department_id
HAVING AVG(salary) BETWEEN 50000 AND 100000;
Q18
Single Choice

Which of the following ORACLE SQL queries will return departments where the maximum salary is more than 120,000 and the minimum salary is less than 40,000?

Q19
Single Choice

In ORACLE, what would be the result of using a HAVING clause without a GROUP BY clause?

Q20
Single Choice

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

SQL Code
SELECT job_id, COUNT(*)
FROM employees
GROUP BY job_id
HAVING COUNT(*) > ALL (SELECT COUNT(*) FROM employees GROUP BY department_id);
Q21
Multiple Choice

Which SQL code snippet correctly uses the HAVING clause to filter departments with an average salary greater than $50,000 in Oracle?

SQL Code
SELECT department_id, AVG(salary) AS avg_salary
FROM employees
GROUP BY department_id
HAVING AVG(salary) > 50000;

SELECT department_id, AVG(salary)
FROM employees
GROUP BY department_id
HAVING AVG(salary) > 50000;

SELECT department_id, AVG(salary) avg_salary
FROM employees
GROUP BY department_id
HAVING AVG(salary) > 50000;
Q22
Multiple Choice

Which SQL code snippet demonstrates how to use the HAVING clause to filter product categories with total sales greater than $100,000 in Oracle?

SQL Code
SELECT category_id, SUM(sales_amount) AS total_sales
FROM sales
GROUP BY category_id
HAVING SUM(sales_amount) > 100000;

SELECT category_id, SUM(sales_amount)
FROM sales
GROUP BY category_id
HAVING SUM(sales_amount) > 100000;

SELECT category_id, SUM(sales_amount) total_sales
FROM sales
GROUP BY category_id
HAVING SUM(sales_amount) > 100000;
Q23
Multiple Choice

Which SQL code snippet uses the HAVING clause to filter employees by job title where the average salary is less than $40,000 in Oracle?

SQL Code
SELECT job_title, AVG(salary) AS avg_salary
FROM employees
GROUP BY job_title
HAVING AVG(salary) < 40000;

SELECT job_title, AVG(salary)
FROM employees
GROUP BY job_title
HAVING AVG(salary) < 40000;

SELECT job_title, AVG(salary) avg_salary
FROM employees
GROUP BY job_title
HAVING AVG(salary) < 40000;
Q24
Multiple Choice

Which SQL code snippet demonstrates advanced use of the HAVING clause to filter departments where the total number of employees is greater than 10 in Oracle?

SQL Code
SELECT department_id, COUNT(*) AS num_employees
FROM employees
GROUP BY department_id
HAVING COUNT(*) > 10;

SELECT department_id, COUNT(*)
FROM employees
GROUP BY department_id
HAVING COUNT(*) > 10;

SELECT department_id, COUNT(*) num_employees
FROM employees
GROUP BY department_id
HAVING COUNT(*) > 10;
Q25
Multiple Choice

Which SQL code snippet uses the HAVING clause to filter regions where the total sales amount is between $200,000 and $500,000 in Oracle?

SQL Code
SELECT region_id, SUM(sales_amount) AS total_sales
FROM sales
GROUP BY region_id
HAVING SUM(sales_amount) BETWEEN 200000 AND 500000;

SELECT region_id, SUM(sales_amount)
FROM sales
GROUP BY region_id
HAVING SUM(sales_amount) BETWEEN 200000 AND 500000;

SELECT region_id, SUM(sales_amount) total_sales
FROM sales
GROUP BY region_id
HAVING SUM(sales_amount) BETWEEN 200000 AND 500000;
Q26
Multiple Choice

Which SQL code snippet demonstrates certification-level use of the HAVING clause to filter customers by their total purchase amount in Oracle?

SQL Code
SELECT customer_id, SUM(purchase_amount) AS total_purchases
FROM purchases
GROUP BY customer_id
HAVING SUM(purchase_amount) > 10000;

SELECT customer_id, SUM(purchase_amount)
FROM purchases
GROUP BY customer_id
HAVING SUM(purchase_amount) > 10000;

SELECT customer_id, SUM(purchase_amount) total_purchases
FROM purchases
GROUP BY customer_id
HAVING SUM(purchase_amount) > 10000;
Q27
Multiple Choice

Which SQL code snippet uses the HAVING clause to filter suppliers by the number of products they supply in Oracle?

SQL Code
SELECT supplier_id, COUNT(*) AS num_products
FROM products
GROUP BY supplier_id
HAVING COUNT(*) > 50;

SELECT supplier_id, COUNT(*)
FROM products
GROUP BY supplier_id
HAVING COUNT(*) > 50;

SELECT supplier_id, COUNT(*) num_products
FROM products
GROUP BY supplier_id
HAVING COUNT(*) > 50;
Q28
Multiple Choice

Which SQL code snippet demonstrates advanced use of the HAVING clause to filter orders by their total value in Oracle?

SQL Code
SELECT order_id, SUM(order_value) AS total_value
FROM orders
GROUP BY order_id
HAVING SUM(order_value) > 1000;

SELECT order_id, SUM(order_value)
FROM orders
GROUP BY order_id
HAVING SUM(order_value) > 1000;

SELECT order_id, SUM(order_value) total_value
FROM orders
GROUP BY order_id
HAVING SUM(order_value) > 1000;
Q29
Multiple Choice

Which SQL code snippet uses the HAVING clause to filter sales by region where the total revenue exceeds $1,000,000 in Oracle?

SQL Code
SELECT region_id, SUM(revenue) AS total_revenue
FROM sales
GROUP BY region_id
HAVING SUM(revenue) > 1000000;

SELECT region_id, SUM(revenue)
FROM sales
GROUP BY region_id
HAVING SUM(revenue) > 1000000;

SELECT region_id, SUM(revenue) total_revenue
FROM sales
GROUP BY region_id
HAVING SUM(revenue) > 1000000;
Q30
Multiple Choice

Which SQL code snippet demonstrates certification-level use of the HAVING clause to filter projects by the average cost in Oracle?

SQL Code
SELECT project_id, AVG(cost) AS avg_cost
FROM projects
GROUP BY project_id
HAVING AVG(cost) > 50000;

SELECT project_id, AVG(cost)
FROM projects
GROUP BY project_id
HAVING AVG(cost) > 50000;

SELECT project_id, AVG(cost) avg_cost
FROM projects
GROUP BY project_id
HAVING AVG(cost) > 50000;