Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> comp.databases.theory -> Transform Rows into Columns

Transform Rows into Columns

From: Felix <felix666007_no_solicitation_at_yahoo.com>
Date: 6 Oct 2003 16:22:27 -0700
Message-ID: <80c2794f.0310061522.10ffc6a8@posting.google.com>


I have three tables:

Table Race

RaceID		RaceDescription
=======		================
1		100 Yard Dash

Table Racer
RacerId		RacerName
========	=========
1		Freddy
2		Joey
3		Iggy

Table Lap
LapId	RacerId	RaceId	LapNum	LapTime
=====	======	======	======	======	
1	1	1	1	32.44
2	1	1	2	31.64
3	1	1	3	31.53
4	1	1	4	31.46
5	1	1	5	33.18
6	2	1	1	39.83
7	2	1	2	37.49
8	2	1	3	37.70
9	2	1	4	36.02
10	2	1	5	36.48
11	3	1	1	37.58
12	3	1	2	33.63
13	3	1	3	32.86
14	3	1	4	32.66
15	3	1	5	32.76


I want to do a query that will produce a result set that looks like:

LapNum	Freddy	Joey	Iggy
======	======	======	======
1	32.44	39.83	37.58
2	31.64	37.49	33.63
3	31.53	37.70	32.86
4	31.46	36.02	32.66
5	33.18	36.48	32.76

Note: I am using Sql Server 2000

Thanks for the help!

Felix Received on Mon Oct 06 2003 - 18:22:27 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US