Q1
True / FalseIn Oracle, the GROUP BY clause is used to group rows that have the same values in specified columns into summary rows.
The GROUP BY clause groups rows that share the same values in the specified columns and allows aggregate functions to be applied to each group.
Q2
True / FalseThe GROUP BY clause must be used with an aggregate function such as SUM, COUNT, AVG, MIN, or MAX in Oracle.
The GROUP BY clause is typically used with aggregate functions to perform calculations on each group of rows.
Q3
True / FalseIn Oracle, columns in the GROUP BY clause must also appear in the SELECT list unless they are used with an aggregate function.
Columns in the GROUP BY clause must be included in the SELECT list unless they are arguments to aggregate functions.
Q4
True / FalseIn Oracle, the GROUP BY clause can be used with the ORDER BY clause to sort the grouped result set.
The GROUP BY clause can be followed by the ORDER BY clause to sort the grouped result set.
Q5
True / FalseIn Oracle, you can use column aliases defined in the SELECT clause in the GROUP BY clause.
Column aliases defined in the SELECT clause cannot be used in the GROUP BY clause. The original column names must be used.
Q6
True / FalseThe GROUP BY clause in Oracle can group by expressions, including calculated columns and functions.
The GROUP BY clause can include expressions, such as calculated columns and functions, to group rows.
Q7
True / FalseIn Oracle, the GROUP BY clause can be used in combination with the HAVING clause to filter groups based on aggregate values.
The HAVING clause is used in conjunction with the GROUP BY clause to filter groups based on aggregate values.
Q8
True / FalseIn Oracle, the GROUP BY clause can be used to group by multiple columns, resulting in a multi-level grouping.
The GROUP BY clause can include multiple columns to create multi-level groupings.
Q9
True / FalseThe GROUP BY clause in Oracle can be used with the ROLLUP and CUBE extensions to generate subtotals and grand totals.
The ROLLUP and CUBE extensions can be used with the GROUP BY clause to generate subtotals and grand totals for different levels of grouping.
Q10
True / FalseThe Oracle Certified Professional (OCP) exam includes knowledge on using the GROUP BY clause effectively, optimizing its performance, and understanding its interaction with aggregate functions and extensions like ROLLUP and CUBE.
The OCP certification covers advanced topics, including the effective use of the GROUP BY clause, optimizing its performance, and understanding its interaction with aggregate functions and extensions like ROLLUP and CUBE.
Q26
Multiple ChoiceWhich SQL code snippet demonstrates advanced use of the GROUP BY clause to calculate the average salary and group by department and job title in Oracle?
SQL Code
SELECT department_id, job_title, AVG(salary) AS avg_salary
FROM employees
GROUP BY department_id, job_title;
SELECT department_id, job_title, AVG(salary)
FROM employees
GROUP BY department_id, job_title;
SELECT department_id, job_title, AVG(salary) avg_salary
FROM employees
GROUP BY department_id, job_title;
Options A, B, and C correctly use the GROUP BY clause to calculate the average salary and group by department and job title. Option D is incorrect because it does not group by job title.
Q30
Multiple ChoiceWhich SQL code snippet uses the GROUP BY clause with multiple columns to group sales by region and product category in Oracle?
SQL Code
SELECT r.region_name, p.category_name, SUM(s.sales_amount) AS total_sales
FROM sales s
JOIN regions r ON s.region_id = r.region_id
JOIN products p ON s.product_id = p.product_id
GROUP BY r.region_name, p.category_name;
SELECT region_name, category_name, SUM(sales_amount)
FROM sales s
JOIN regions r ON s.region_id = r.region_id
JOIN products p ON s.product_id = p.product_id
GROUP BY region_name, category_name;
SELECT r.region_name, p.category_name, SUM(sales_amount) total_sales
FROM sales s
JOIN regions r ON s.region_id = r.region_id
JOIN products p ON s.product_id = p.product_id
GROUP BY r.region_name, p.category_name;
Options A, B, and C correctly use the GROUP BY clause with multiple columns to group sales by region and product category. Option D is incorrect because it does not include the JOINs.