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)
 Pivot Table

Author  Topic 

dewacorp.alliances

452 Posts

Posted - 2008-03-28 : 15:46:10
Hi Guru
I have 2 simplified tables like this

CREATE TABLE [FormAnswers] (
[FormAnswerID] [bigint] IDENTITY (1, 1) NOT NULL ,
[FormQuestionID] [bigint] NULL ,
[UserID] [bigint] NULL ,
[FormAnswer1] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[FormAnswer2] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL) ON [PRIMARY]
GO

CREATE TABLE [FormQuestions] (
[FormQuestionID] [bigint] IDENTITY (1, 1) NOT NULL ,
[FormID] [bigint] NULL ,
[FormQuestionTypeID] [int] NULL ,
[DisplayOrder] [int] NULL ,
[FormQuestionCode] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[FormQuestionName] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[FormQuestionText] [varchar] (500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO

I want to create a pivot report that somehow like this:

====================================================================
|*Questions*|**********UserID1**********|**********UserID2 etc******
|*********|*FormAnswer1*|*FormAnswer2**|*FormAnswer1*|*FormAnswer2*
====================================================================
| Your Name | Yes | N/A | No | Yes
| Your age | 1 | <null> | 2 | <null>
etc

Thank you


rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-03-28 : 22:57:16
Take look at 'cross-tab report' in books online.
Go to Top of Page
   

- Advertisement -