Semi Unpivot Data
In this example, we will demonstrate how to semi-unpivot data.
We have a source sheet / table containg "Date" and "9_A, 9_B, 9_C, 10_A, 10_B, 10_C" and so on columns. And here 9_A means Grade 9th and A Section.
Now our target is to unpivot this type of data into multiple columns where sections are columns and date and Grade will be rows
So if you see here we are not unpivoting all data we are unpivoting and also keep unpivoted data.
I have also seen very interesting topic related with unpivot using Cross Apply. You may refer the link https://www.mssqltips.com/sqlservertip/7835/unpivot-data-sql-server-cross-apply.
| Input Data | Output Data |
|---|---|
This is an example we'll trying to unpivot data using T-SQL
We will use the following query to unpivot data
No comments:
Post a Comment