PostgreSQL Database Quiz Questions

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

PostgreSQL has a built-in PIVOT function that can be used directly in SQL queries.

Q2
True / False

The crosstab function in PostgreSQL requires the tablefunc extension to be enabled.

Q3
True / False

In PostgreSQL, the crosstab function can pivot data without specifying the columns in advance.

Q4
True / False

You can use the crosstab function in PostgreSQL to transform rows into columns based on the values of a specified attribute.

Q5
True / False

The first parameter of the crosstab function in PostgreSQL is a SQL query that returns three columns.

Q6
True / False

In PostgreSQL, you can use window functions as an alternative to pivoting data when using crosstab is not suitable.

Q7
True / False

In PostgreSQL, the crosstab function can only handle a fixed number of pivot columns, which must be known beforehand.

Q8
True / False

To dynamically pivot data in PostgreSQL without knowing the column names in advance, you can use dynamic SQL and procedural code.

Q9
True / False

The crosstab function in PostgreSQL can be used in conjunction with the GROUP BY clause to aggregate data before pivoting.

Q10
True / False

PostgreSQL provides a built-in function called pivot_table for easily transforming row data into columns.

Q11
Single Choice

In PostgreSQL, which SQL operation is commonly used to perform a PIVOT transformation on a dataset?

Q12
Single Choice

Which PostgreSQL extension must be enabled to use the crosstab function for PIVOT operations?

Q13
Single Choice

What is the first step in using the crosstab function in PostgreSQL?

Q14
Single Choice

Which crosstab query will PIVOT this data to show products as columns?

SQL Code
month	product	amount
Jan	A	100
Jan	B	150
Feb	A	200
Feb	B	250
Q15
Single Choice

What will be the output columns when using the crosstab function on the following query in PostgreSQL?

SQL Code
SELECT * FROM crosstab('SELECT month, product, amount FROM sales ORDER BY 1,2')
AS ct(month text, A int, B int);
Q16
Single Choice

How do you specify the output column names in a PostgreSQL crosstab function?

Q17
Single Choice

Which crosstab query will PIVOT this data to include only the months "Jan" and "Feb" as row headers and "A" and "B" as columns?

SQL Code
month	product	amount
Jan	A	100
Jan	B	150
Feb	A	200
Feb	B	250
Mar	A	300
Mar	B	350
Q18
Single Choice

In PostgreSQL, what happens if the crosstab function encounters a category with no data for a particular row?

Q19
Single Choice

Which of the following best describes the crosstab function in PostgreSQL when applied to large datasets?

Q20
Single Choice

How would you write a crosstab query in PostgreSQL to PIVOT this data by month as row headers and product as columns, with a dynamically generated column list?

SQL Code
month	product	amount
Jan	A	100
Jan	B	150
Feb	A	200
Feb	B	250
Mar	A	300
Mar	B	350
Apr	A	400
Apr	B	450
Q21
Multiple Choice

Which SQL queries correctly use the PIVOT functionality in PostgreSQL to transform data?

Q22
Multiple Choice

Identify the SQL queries that correctly apply PIVOT-like transformations using conditional aggregation in PostgreSQL.

Q23
Multiple Choice

Which SQL queries correctly use the PIVOT-like functionality in PostgreSQL to summarize data?

Q24
Multiple Choice

Determine the SQL queries that correctly implement PIVOT-like transformations for attendance records in PostgreSQL.

Q25
Multiple Choice

Identify the SQL queries that correctly use PIVOT-like functionality to transform and aggregate sales data in PostgreSQL.

Q26
Multiple Choice

Which SQL queries correctly use PIVOT-like functionality in PostgreSQL for financial data transformation?

Q27
Multiple Choice

Determine the SQL queries that correctly implement PIVOT-like transformations for project management data in PostgreSQL.

Q28
Multiple Choice

Which SQL queries correctly use PIVOT-like functionality to transform and aggregate survey data in PostgreSQL?

Q29
Multiple Choice

Identify the SQL queries that correctly use PIVOT-like functionality in PostgreSQL for employee shift data.

Q30
Multiple Choice

Which SQL queries correctly use PIVOT-like functionality in PostgreSQL for customer order data?