Oracle Database Quiz Questions

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

In Oracle, the PIVOT operator is used to rotate rows into columns.

Q2
True / False

The PIVOT operator in Oracle can only be used with numeric data types.

Q3
True / False

In Oracle, the PIVOT clause must include an aggregate function such as SUM, COUNT, or AVG.

Q4
True / False

In Oracle, the PIVOT clause can be used in combination with the UNPIVOT clause in the same query.

Q5
True / False

The PIVOT clause in Oracle allows for multiple aggregate functions to be used simultaneously.

Q6
True / False

In Oracle, you can use column aliases within the PIVOT clause to rename the pivoted columns.

Q7
True / False

In Oracle, the PIVOT operator can be used in subqueries to create complex pivoted datasets.

Q8
True / False

The PIVOT clause in Oracle can be optimized using indexes on the columns involved in the pivot operation.

Q9
True / False

In Oracle, the PIVOT operator can only pivot data based on one column at a time.

Q10
True / False

The Oracle Certified Professional (OCP) exam includes knowledge on using the PIVOT operator effectively, optimizing its performance, and understanding its syntax and use cases in complex SQL queries.

Q11
Single Choice

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

Q12
Single Choice

Which of the following is a required component of an ORACLE SQL PIVOT clause?

Q13
Single Choice

What does the following ORACLE SQL query do?

SQL Code
SELECT *
FROM sales
PIVOT (SUM(amount) FOR product_id IN (101, 102, 103));
Q14
Single Choice

In ORACLE SQL, which part of the PIVOT clause specifies the values to be transposed into columns?

Q15
Single Choice

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

SQL Code
SELECT *
FROM employees
PIVOT (COUNT(employee_id) FOR department_id IN (10, 20, 30));
Q16
Single Choice

Which of the following ORACLE SQL queries correctly uses PIVOT to display sales amounts by region?

Q17
Single Choice

What is the result of using multiple aggregate functions within the PIVOT clause in ORACLE SQL?

Q18
Single Choice

Consider the following ORACLE SQL query:What will this query return?

SQL Code
SELECT *
FROM orders
PIVOT (SUM(order_total) AS total, COUNT(order_id) AS order_count FOR order_date IN ('2023-01-01', '2023-01-02'));
Q19
Single Choice

Which of the following ORACLE SQL queries will correctly transpose department names into columns showing the average salary of employees in each department?

Q20
Single Choice

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

SQL Code
SELECT *
FROM (SELECT department_id, employee_id, salary FROM employees)
PIVOT (MAX(salary) FOR department_id IN (10, 20, 30));
Q21
Multiple Choice

Which SQL code snippet demonstrates the use of SQL PIVOT to transform rows into columns for monthly sales data in Oracle?

SQL Code
SELECT *
FROM (SELECT sale_month, product_name, sale_amount
FROM sales)
PIVOT (SUM(sale_amount) FOR sale_month IN ('Jan', 'Feb', 'Mar'));

SELECT *
FROM (SELECT sale_month, product_name, sale_amount
FROM sales)
PIVOT (SUM(sale_amount) FOR sale_month IN ('Jan', 'Feb', 'Mar'));

SELECT product_name, 'Jan' AS January, 'Feb' AS February, 'Mar' AS March
FROM (SELECT sale_month, product_name, sale_amount
FROM sales)
PIVOT (SUM(sale_amount) FOR sale_month IN ('Jan', 'Feb', 'Mar'));
Q22
Multiple Choice

Which SQL code snippet uses SQL PIVOT to display the total sales amount per product for each quarter in Oracle?

SQL Code
SELECT *
FROM (SELECT product_name, quarter, sale_amount
FROM sales)
PIVOT (SUM(sale_amount) FOR quarter IN ('Q1', 'Q2', 'Q3', 'Q4'));

SELECT *
FROM (SELECT product_name, quarter, sale_amount
FROM sales)
PIVOT (SUM(sale_amount) FOR quarter IN ('Q1', 'Q2', 'Q3', 'Q4'));

SELECT product_name, 'Q1' AS Q1, 'Q2' AS Q2, 'Q3' AS Q3, 'Q4' AS Q4
FROM (SELECT product_name, quarter, sale_amount
FROM sales)
PIVOT (SUM(sale_amount) FOR quarter IN ('Q1', 'Q2', 'Q3', 'Q4'));
Q23
Multiple Choice

Which SQL code snippet demonstrates the use of SQL PIVOT to calculate the average sales amount per region for each month in Oracle?

SQL Code
SELECT *
FROM (SELECT region_name, sale_month, sale_amount
FROM sales)
PIVOT (AVG(sale_amount) FOR sale_month IN ('Jan', 'Feb', 'Mar', 'Apr'));

SELECT *
FROM (SELECT region_name, sale_month, sale_amount
FROM sales)
PIVOT (AVG(sale_amount) FOR sale_month IN ('Jan', 'Feb', 'Mar', 'Apr'));

SELECT region_name, 'Jan' AS January, 'Feb' AS February, 'Mar' AS March, 'Apr' AS April
FROM (SELECT region_name, sale_month, sale_amount
FROM sales)
PIVOT (AVG(sale_amount) FOR sale_month IN ('Jan', 'Feb', 'Mar', 'Apr'));
Q24
Multiple Choice

Which SQL code snippet demonstrates advanced use of SQL PIVOT to display total sales by category for different years in Oracle?

SQL Code
SELECT *
FROM (SELECT category_name, sale_year, sale_amount
FROM sales)
PIVOT (SUM(sale_amount) FOR sale_year IN (2019, 2020, 2021));

SELECT *
FROM (SELECT category_name, sale_year, sale_amount
FROM sales)
PIVOT (SUM(sale_amount) FOR sale_year IN (2019, 2020, 2021));

SELECT category_name, '2019' AS Year_2019, '2020' AS Year_2020, '2021' AS Year_2021
FROM (SELECT category_name, sale_year, sale_amount
FROM sales)
PIVOT (SUM(sale_amount) FOR sale_year IN (2019, 2020, 2021));
Q25
Multiple Choice

Which SQL code snippet demonstrates the use of SQL PIVOT to find the maximum sales per employee for each region in Oracle?

SQL Code
SELECT *
FROM (SELECT employee_name, region_name, sale_amount
FROM sales)
PIVOT (MAX(sale_amount) FOR region_name IN ('North', 'South', 'East', 'West'));

SELECT *
FROM (SELECT employee_name, region_name, sale_amount
FROM sales)
PIVOT (MAX(sale_amount) FOR region_name IN ('North', 'South', 'East', 'West'));

SELECT employee_name, 'North' AS North_Region, 'South' AS South_Region, 'East' AS East_Region, 'West' AS West_Region
FROM (SELECT employee_name, region_name, sale_amount
FROM sales)
PIVOT (MAX(sale_amount) FOR region_name IN ('North', 'South', 'East', 'West'));
Q26
Multiple Choice

Which SQL code snippet demonstrates advanced use of SQL PIVOT to generate a report showing the total sales amount by quarter and product category in Oracle?

SQL Code
SELECT *
FROM (SELECT category_name, quarter, sale_amount
FROM sales)
PIVOT (SUM(sale_amount) FOR quarter IN ('Q1', 'Q2', 'Q3', 'Q4'));

SELECT *
FROM (SELECT category_name, quarter, sale_amount
FROM sales)
PIVOT (SUM(sale_amount) FOR quarter IN ('Q1', 'Q2', 'Q3', 'Q4'));

SELECT category_name, 'Q1' AS Q1_Sales, 'Q2' AS Q2_Sales, 'Q3' AS Q3_Sales, 'Q4' AS Q4_Sales
FROM (SELECT category_name, quarter, sale_amount
FROM sales)
PIVOT (SUM(sale_amount) FOR quarter IN ('Q1', 'Q2', 'Q3', 'Q4'));
Q27
Multiple Choice

Which SQL code snippet demonstrates certification-level use of SQL PIVOT to analyze sales data by product and year in Oracle?

SQL Code
SELECT *
FROM (SELECT product_name, sale_year, sale_amount
FROM sales)
PIVOT (SUM(sale_amount) FOR sale_year IN (2018, 2019, 2020, 2021));

SELECT *
FROM (SELECT product_name, sale_year, sale_amount
FROM sales)
PIVOT (SUM(sale_amount) FOR sale_year IN (2018, 2019, 2020, 2021));

SELECT product_name, '2018' AS Year_2018, '2019' AS Year_2019, '2020' AS Year_2020, '2021' AS Year_2021
FROM (SELECT product_name, sale_year, sale_amount
FROM sales)
PIVOT (SUM(sale_amount) FOR sale_year IN (2018, 2019, 2020, 2021));
Q28
Multiple Choice

Which SQL code snippet demonstrates certification-level use of SQL PIVOT to compare sales performance across different stores and quarters in Oracle?

SQL Code
SELECT *
FROM (SELECT store_name, quarter, sale_amount
FROM sales)
PIVOT (SUM(sale_amount) FOR quarter IN ('Q1', 'Q2', 'Q3', 'Q4'));

SELECT *
FROM (SELECT store_name, quarter, sale_amount
FROM sales)
PIVOT (SUM(sale_amount) FOR quarter IN ('Q1', 'Q2', 'Q3', 'Q4'));

SELECT store_name, 'Q1' AS Q1_Sales, 'Q2' AS Q2_Sales, 'Q3' AS Q3_Sales, 'Q4' AS Q4_Sales
FROM (SELECT store_name, quarter, sale_amount
FROM sales)
PIVOT (SUM(sale_amount) FOR quarter IN ('Q1', 'Q2', 'Q3', 'Q4'));
Q29
Multiple Choice

Which SQL code snippet demonstrates certification-level use of SQL PIVOT to generate a dynamic report showing sales trends by month and region in Oracle?

SQL Code
SELECT *
FROM (SELECT region_name, sale_month, sale_amount
FROM sales)
PIVOT (SUM(sale_amount) FOR sale_month IN ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'));

SELECT *
FROM (SELECT region_name, sale_month, sale_amount
FROM sales)
PIVOT (SUM(sale_amount) FOR sale_month IN ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'));

SELECT region_name, 'Jan' AS January, 'Feb' AS February, 'Mar' AS March, 'Apr' AS April, 'May' AS May, 'Jun' AS June, 'Jul' AS July, 'Aug' AS August, 'Sep' AS September, 'Oct' AS October, 'Nov' AS November, 'Dec' AS December
FROM (SELECT region_name, sale_month, sale_amount
FROM sales)
PIVOT (SUM(sale_amount) FOR sale_month IN ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'));
Q30
Multiple Choice

Which SQL code snippet demonstrates certification-level use of SQL PIVOT to create a multi-dimensional analysis report for sales by product, year, and region in Oracle?

SQL Code
SELECT *
FROM (SELECT product_name, sale_year, region_name, sale_amount
FROM sales)
PIVOT (SUM(sale_amount) FOR (sale_year, region_name) IN ((2019, 'North'), (2019, 'South'), (2020, 'North'), (2020, 'South')));

SELECT *
FROM (SELECT product_name, sale_year, region_name, sale_amount
FROM sales)
PIVOT (SUM(sale_amount) FOR (sale_year, region_name) IN ((2019, 'North'), (2019, 'South'), (2020, 'North'), (2020, 'South')));

SELECT product_name, '2019_North' AS '2019 North', '2019_South' AS '2019 South', '2020_North' AS '2020 North', '2020_South' AS '2020 South'
FROM (SELECT product_name, sale_year, region_name, sale_amount
FROM sales)
PIVOT (SUM(sale_amount) FOR (sale_year, region_name) IN ((2019, 'North'), (2019, 'South'), (2020, 'North'), (2020, 'South')));