SQL
PIVOT Statement
The `PIVOT` statement allows distinct values within a column to be separated into their own columns.
The values within those new columns are calculated using an aggregate function on the subset of rows that match each distinct value.  
DuckDB implements both the SQL Standard `PIVOT` syntax and a simplified `PIVOT` syntax that automatically detects the columns to create while pivoting.
`PIVOT_WIDER` may also be used in place of the `PIVOT` keyword.  
For details on how the `PIVOT` statement is implemented, see the [Pivot Internals site](#docs:internals:pivot::pivot).  
> The [`UNPIVOT` statement](#docs:sql:statements:unpivot) is the inverse of the `PIVOT` statement.