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 2005 Forums
 Transact-SQL (2005)
 grid type display

Author  Topic 

joemama
Posting Yak Master

113 Posts

Posted - 2007-12-05 : 01:41:23
I am not sure what it is correctly called but i have the below query
that i need to display in a grid with the UserID down the side and the Month accross the top...like this



USERID | JAN | FEB | MAR | APR | ETC
2345
7654
2567
3456

HERE IS THE QUERY... I NEED ALL THE DATA TO BE IN SEPERATE MONTH COLUMNS

IS THERE A WAY TO DO IT?


SELECT dbo.WTournament_Results.TRID, dbo.WTournament_Results.TID, dbo.WUsers.UserFirstName, dbo.WUsers.UserLastName,
dbo.WTournament_Results.TRPartner, dbo.WTournament_Results.TRTotalWt, dbo.WTournament_Results.TRBigFishWt,
dbo.WTournament_Results.TRFishDead, dbo.WTournament_Results.TRFishCaught, dbo.WTournament_Results.TRPlace,
dbo.WTournament_Results.TRPartnerWt, dbo.WTournament_Results.TRDebriefPoints,dbo.WTournament_Results.TRMtgPoints,dbo.WTournament_Points.Points AS TRPoints
FROM dbo.WTournament_Results INNER JOIN
dbo.WTournaments ON dbo.WTournament_Results.TID = dbo.WTournaments.tournID INNER JOIN
dbo.WTournament_Points ON dbo.WTournament_Results.TRPlace = dbo.WTournament_Points.Place LEFT OUTER JOIN
dbo.WUsers ON dbo.WTournament_Results.TRUserID = dbo.WUsers.UserID

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2007-12-05 : 11:30:55
Use PIVOT functionality to get the data onto column format. Refer to BOL for example usage.
Go to Top of Page

joemama
Posting Yak Master

113 Posts

Posted - 2007-12-05 : 13:44:59
thanks!

quote:
Originally posted by visakh16

Use PIVOT functionality to get the data onto column format. Refer to BOL for example usage.

Go to Top of Page
   

- Advertisement -