SELECT CLASS,
isnull([AZ],0),
isnull([CA],0),
isnull([TX],0)
FROM #TEMP
PIVOT (SUM(DATA)
FOR STATE IN ([AZ], [CA], [TX])) AS PVT
ORDER BY CLASS
More Related Contents:
- SQL query rows as columns [duplicate]
- SQL Server dynamic PIVOT query?
- Efficiently convert rows to columns in sql server
- Convert Rows to columns using ‘Pivot’ in SQL Server
- Simple way to transpose columns and rows in SQL?
- T-SQL dynamic pivot
- SQL transpose full table
- SQL Server 2005 Pivot on Unknown Number of Columns
- TSQL Pivot without aggregate function
- Dynamically create columns sql
- TSQL PIVOT MULTIPLE COLUMNS
- Dynamic Pivot Columns in SQL Server
- SQL Server : dynamic pivot over 5 columns
- Pivot Table and Concatenate Columns
- Dynamic Pivot Table in SQL Server
- Pivot data in T-SQL
- PIVOT query on Distinct records
- SQL Server PIVOT perhaps?
- In SQL Server how to Pivot for multiple columns
- Using PIVOT in SQL Server 2008
- Creating stored procedure getting Incorrect syntax near the keyword ‘Declare’
- Conversion failed when converting date and/or time from character string while inserting datetime
- Get the last inserted row ID (with SQL statement) [duplicate]
- Run all SQL files in a directory
- unresolved reference to object [INFORMATION_SCHEMA].[TABLES]
- Selecting first row per group
- How do I specify date literal when writing SQL query from SQL Server that is linked to Oracle?
- How do I change db schema to dbo
- Sql Server : How to use an aggregate function like MAX in a WHERE clause
- How to insert into a table with just one IDENTITY column?