
Ultimate access to all questions.
Answer-first summary for fast verification
Answer: PIVOT
The PIVOT keyword in SQL is specifically designed to convert data from a long format (where each row represents a single observation) to a wide format (where each row represents multiple observations across columns). **Key Points:** - **PIVOT** rotates data from rows to columns, aggregating values as needed - **TRANSFORM** is not a standard SQL keyword for this purpose - **SUM** is an aggregation function, not a format conversion operation - **CONVERT** is typically used for data type conversions, not format restructuring - **WHERE** is a filtering clause, not for data reshaping In Databricks SQL and Spark SQL, PIVOT is the correct operation for converting long format data to wide format by specifying which column values should become new column headers.
Author: Keng Suppaseth
No comments yet.