Skip to content

Commit 8beeb22

Browse files
authored
Merge pull request #13785 from WilliamAntonRohm/issue-4080
sql-docs issue 4080 -- was missing "UNPIVOT Example" heading
2 parents 68aa28f + c838650 commit 8beeb22

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

docs/t-sql/queries/from-using-pivot-and-unpivot.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ The unique values returned by the `EmployeeID` column become fields in the final
151151

152152
> [!IMPORTANT]
153153
> When aggregate functions are used with `PIVOT`, the presence of any null values in the value column are not considered when computing an aggregation.
154+
155+
## UNPIVOT Example
154156

155157
`UNPIVOT` carries out almost the reverse operation of `PIVOT`, by rotating columns into rows. Suppose the table produced in the previous example is stored in the database as `pvt`, and you want to rotate the column identifiers `Emp1`, `Emp2`, `Emp3`, `Emp4`, and `Emp5` into row values that correspond to a particular vendor. As such, you must identify two additional columns. The column that will contain the column values that you're rotating (`Emp1`, `Emp2`,...) will be called `Employee`, and the column that will hold the values that currently exist under the columns being rotated will be called `Orders`. These columns correspond to the *pivot_column* and *value_column*, respectively, in the [!INCLUDE[tsql](../../includes/tsql-md.md)] definition. Here is the query.
156158

0 commit comments

Comments
 (0)