
Ultimate access to all questions.
Which SQL keyword can be used to convert a table from a long format to a wide format?
A
TRANSFORM
B
PIVOT
C
SUM
D
CONVERT
Explanation:
The correct answer is B. PIVOT.
SELECT *
FROM sales_data
PIVOT (
SUM(amount)
FOR product IN ('A', 'B', 'C')
)
SELECT *
FROM sales_data
PIVOT (
SUM(amount)
FOR product IN ('A', 'B', 'C')
)
This would convert long-format sales data (with rows for each product) into wide format (with columns for each product).