Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pivot Query Columns to Records

Status
Not open for further replies.

JustATheory

IS-IT--Management
Feb 27, 2003
115
US
Greetings,

Is there a way to do a simple pivot query to list columns as records. Here is my example of table and result table

OriginalTable

CatA CatB CatC
Vol 1 2 3
Vol 2 3 4
Vol 5 6 7

ResultTable

Vol
CatA 6
CatB 9
CatC 18

Thanks in advance,
JustATheory
 
select 'CatA', CatA
from OriginalTable

union all

select 'CatB', CatB
from OriginalTable

Union All

select 'CatC', CatC
from OriginalTable

Simi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top