In data modeling and analysis, "rotating" data is a common task used to normalize datasets for reporting or visualization. The operation of taking multiple columns (like the individual months in the source image) and turning them into values within a single column (like the "MONTH" column in the target image) is specifically known as unpivoting.
The UNPIVOT relational operator in Snowflake allows an analyst to transform a "wide" table format into a "narrow" (or "long") table format. In the wide format shown in the first image, data is distributed across columns named JAN, FEB, MAR, and APRIL. While this is often easier for humans to read in a spreadsheet, it is difficult to query for trends. By applying UNPIVOT, Snowflake collapses these columns into two new ones: one for the name of the original column (the attribute, such as "MONTH") and one for the value that was stored in that column (the metric, such as "SALES").
Evaluating the Options:
Option A (PIVOT) is the opposite of the required action. It is used to turn unique values from one column into multiple separate columns (narrow to wide), which is not what is happening in the exhibit.
Option C (INTERSECT) is a set operator that returns only the distinct rows that are present in both the first and second query results. It does not perform data rotation.
Option D (EXCEPT) is a set operator that returns rows from the first query that are not present in the second.
Option B is the 100% correct answer. It is the dedicated relational operator for converting column headers into row values, which is exactly the transformation required to move from the first image to the second. Mastering this operator is a critical skill for any SnowPro Advanced: Data Analyst when preparing messy source data for high-performance analytics.
Contribute your Thoughts:
Chosen Answer:
This is a voting comment (?). You can switch to a simple comment. It is better to Upvote an existing comment if you don't have anything to add.
Submit