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)
 Famous Last Words: "Sure that'll be no problem"

Author  Topic 

PiecesOfEight
Posting Yak Master

200 Posts

Posted - 2001-05-22 : 00:44:15
I'm working on a problem that has had me stumped for a while. After a number of fruitless attempts, I'm asking the experts.

There are 5 tables involved in this problem:

Session
-------
SessionID (PK)

Task
----
TaskID (PK)
TaskTitle

Question
--------
QuestionID (PK)

SessionTask
-----------
SessionID (PK)(FK)
TaskID (PK)(FK)
TaskResponse

SessionQuestion
---------------
SessionID (PK)(FK)
QuestionID (PK)(FK)
QuestionResponse


I need to produce output like so, with a row for each task response, and the question reponses duplicated in each row:
 
Session ID | Task Title | Task Response | Q1 Response | Q2 Response | ... | Q13 Response
----------------------------------------------------------------------------------------
80 task1 response1 q1resp q2resp q13resp
80 task2 response2 q1resp q2resp q13resp
80 task3 response3 q1resp q2resp q13resp
81 task3 response3 q1resp q2resp q13resp


   

- Advertisement -