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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pivot Query SQL Server 2005

Status
Not open for further replies.

JohnCaver

Programmer
May 3, 2007
10
GB
Hi,
I am recording results of matches between various teams in various tournaments.
My columns for the score table are HomeTeam, AwayTeam, Tournament, HomePoints, AwayPoints.

e.g.
HomeTeam|AwayTeam|Tournament|PointsHome|PointsAway
----------------------------------------------------------
A B T1 1 2
A B T2 3 4

I want to pivot this to produce a table like:

HomeTeam|AwayTeam|T1_HomePoints|T1_AwayPoints|T2_HomePoints|T2_AwayPoints
------------------------------------------------------------------------------------
A B 1 2 3 4

Can this be done in SQL Server 2005?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top