Which of the following SQL keywords can be used to convert a table from a long format to a wide format?
Which of the following SQL keywords can be used to convert a table from a long format to a wide format?
In SQL, the PIVOT keyword is used to transform data from a long format to a wide format. This involves turning the unique values of a specified column into multiple columns in the output. It is particularly useful for summarizing data and making it more readable or suitable for certain types of analysis.
PIVOT is correct.
PIVOT is correct.
B is correct
Answer is B
https://docs.databricks.com/en/sql/language-manual/sql-ref-syntax-qry-select-pivot.html “Pivot” transforms the rows of the table_reference by rotating unique values of a specified column list into separate columns. SYNTAX : table_reference PIVOT ( { aggregate_expression [ [ AS ] agg_column_alias ] } [, ...] FOR column_list IN ( expression_list ) ) column_list { column_name | ( column_name [, ...] ) } expression_list { expression [ AS ] [ column_alias ] | { ( expression [, ...] ) [ AS ] [ column_alias] } [, ...] ) }