Pivot Example

Pivot Example.

Last updated:

Warning: Review and test in a non-production environment before running.

Back to results

SELECT ModifiedDate,[0], [1], [2], [3], [4], [5], [6], [7], [8]
FROM
(SELECT ModifiedDate, StateProvinceID, AddressLine1 FROM Person.Address) AS SourceTable
PIVOT
(
COUNT(AddressLine1)
FOR StateProvinceID IN ([0], [1], [2], [3], [4], [5], [6], [7], [8])
) AS PivotTable
order by 1