Groups | Blog | Home
all groups > sql server new users > april 2006 >

sql server new users : How to get started creating a cross tab report?


MickeyD
4/19/2006 10:01:02 AM
Hi,

I am a SQL Server 2005 Newbie. I got the task of getting data from a
reporting server view. I can do basic SQL queries. My question is how do I
get started if I want to create a report without having to import this into
Excel and transpose. I have to extract data from users who answer QA surveys.
The query generates x number of rows based on x number of answers to the
questions. I would like to create report that has the last name, first name
on the row headers and the questions as column headers. The answers would be
underneath the column headers and matched to the last name and first name.

I am really frustrated because I have been told that I need to use the pivot
command or use dynamic cross tabs. Others have told me to put my query as a
subselect then pivot on the result.

Here is my basic query. I just need assistance just to get started.

SELECT Distinct

dbo.uvwReport_SurveyAnswers.DateCreated AS DateCreated

,dbo.uvwReport_SurveyAnswers.userid AS UserID

,dbo.uvw_User.LastName AS LastName

,dbo.uvw_User.FirstName AS FirstName

,dbo.uvwReport_SurveyQuestions.ordernumber AS OrderNumber

,dbo.uvwReport_SurveyQuestions.QuestionText AS QuestionText

,dbo.uvwReport_SurveyAnswers.QuestionAnswer AS QuestionAnswer


FROM

dbo.uvwReport_Surveys

INNER JOIN dbo.uvwReport_SurveyQuestions

ON dbo.uvwReport_Surveys.surveyid = dbo.uvwReport_SurveyQuestions.surveyid

INNER JOIN dbo.uvwReport_SurveyAnswers

ON dbo.uvwReport_SurveyQuestions.QuestionID =
dbo.uvwReport_SurveyAnswers.QuestionID

INNER JOIN dbo.uvw_User

ON dbo.uvwReport_SurveyAnswers.userid = dbo.uvw_User.userid

WHERE

dbo.uvwReport_SurveyAnswers.surveyid = 100

Group by dbo.uvwReport_SurveyAnswers.DateCreated

,dbo.uvwReport_SurveyAnswers.userid

,dbo.uvw_User.LastName

,dbo.uvw_User.FirstName

,dbo.uvwReport_SurveyQuestions.ordernumber

,dbo.uvwReport_SurveyQuestions.QuestionText

,dbo.uvwReport_SurveyAnswers.QuestionAnswer

Thanks



--
Steve Dassin
4/20/2006 7:22:26 PM
You seem to imply that you have an idea of an 'easy' solution
that doesn't involve the below steps.What ideally would you feel
is the approach to this?

www.rac4sql.net

[quoted text, click to view]

MickeyD
4/21/2006 8:55:02 AM
Hi Steve,

Actually, I went with doing a pivot and designating each column since I did
not have to name too many columns. I wasn't too keen on doing a dynamic
cross tab even though you wouldn't need to know exactly how many columns.

MickeyD
--
The Accidental Tourist


[quoted text, click to view]
AddThis Social Bookmark Button