Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Query Setup

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-01-17 : 17:57:35
Gary writes "Is it possible to write a query like a pivot table in Excel?

I am getting the basic answers I need from my queries, but would like to go into more detail.

I would like to have the query give me data in an X and Y structure.

Several colunms at the top that would come from a GROUP BY function, and multiple rows with data in a different GROUP BY function.

I work for American Airlines in Dallas, and am trying to build a query to show live data on our intranet website on how our flight operation is doing during the day. The columns would represent the three Terminals we operate out of here in Dallas, and the rows would provide the different Delay Codes that we charge to a flight when it left the gate late. Here is an example below.

                 Terminals
Delay Codes
A B C

01 1
05 1 1
27B 1 3 2
46 3 2 5
63 2 1 1



I can build a pivot table in excel by using the information that is being stored in SQL, the question is can I build a query that mirrors the pivot table in SQL?

We are using SQL 7 with service pack 1, windows version is NT 4.0


Thanks for all your help!!

Gary Costigan"
   

- Advertisement -