Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PIVOT TABLE - SQL Server 2000

Posted on 2007-04-11
3
Medium Priority
?
276 Views
Last Modified: 2010-05-18
Hello.  I am trying to develop an ASP.NET app that displays linear data as a pivot table, and I have no idea how to go about it. My table is set up like this:
VESSEL
VOYAGE
PORT
ARRIVAL
I want this to display in a table like the following:
VESSEL   VOYAGE   PORT1   PORT2   PORT3   (Ports are different)
vsl1          voy1          date1      date2    date3
vsl2          voy2          date1      date2    date3
vsl3          voy3          date1      date2    date3

Can somebody help me with this? In Access, this is pretty easy, but how do I do this in SQL Server 2000?
0
Comment
Question by:adwooley2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 18

Expert Comment

by:Sham Haque
ID: 18887956
here's a nice explanation of how to achieve this, using CASE:

Creating cross tab queries and pivot tables in SQL
http://www.simple-talk.com/sql/t-sql-programming/creating-cross-tab-queries-and-pivot-tables-in-sql/
0
 
LVL 18

Accepted Solution

by:
Sham Haque earned 2000 total points
ID: 18887975
your example:

SELECT vessel
            ,voyage
            ,port1 = CASE PORT WHEN 'port1' then arrival else null end
            ,port2  = CASE PORT WHEN 'port2' then arrival else null end
            ,port3 = CASE PORT when 'port3' then arrival else null end
FROM voyages
0
 

Author Comment

by:adwooley2
ID: 18888289
Appears easy.  I'll give it a try.  Thanks for your quick response.

Regards,
Alan
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
I have a large data set and a SSIS package. How can I load this file in multi threading?
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question