473,411 Members | 1,980 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Survey results combined

I have two tables first table called userinfo has a field called surveynum and surveyid. the second table has fields such as questionid,questionresult,questioncomment, and surveynum. the two tables are joined by the surveynum field which helps to track back which user and what survey the info is for. Now for the Million dollar question. I need to have a SQL query that will take combine the survey results into one row like such

userid,surveynumber,questionresponse1 ...,questioncomment1...,questionresponse2,question comment2...

in other words I want to take all the responses from one user for a particular survey and group them into one table. I tried group by and union with no luck. I am sure i am just overlooking the obvious.

Any help would be appreciated


I realize i could do this via coding but i would also like to make it a view.
Sep 24 '07 #1
2 1635
azimmer
200 Expert 100+
I have two tables first table called userinfo has a field called surveynum and surveyid. the second table has fields such as questionid,questionresult,questioncomment, and surveynum. the two tables are joined by the surveynum field which helps to track back which user and what survey the info is for. Now for the Million dollar question. I need to have a SQL query that will take combine the survey results into one row like such

userid,surveynumber,questionresponse1 ...,questioncomment1...,questionresponse2,question comment2...

in other words I want to take all the responses from one user for a particular survey and group them into one table. I tried group by and union with no luck. I am sure i am just overlooking the obvious.

Any help would be appreciated


I realize i could do this via coding but i would also like to make it a view.
In SQL Server 2005 there's a PIVOT operator you can use. Read this (even if you use 2000): http://www.databasejournal.com/features/mssql/article.php/3521101

Here's another set for 2000 (works with 2005 but not ideal): http://www.mssqltips.com/tip.asp?tip=937
Sep 25 '07 #2
my data looks like such

38,1,1,"comment"
38,2,1,"comment"
38,3,2,"no comment"

i would like it to be

38,1,"comment",1,"comment",2,"no comment"
Sep 25 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Dan | last post by:
Hi, I want to migrate a survey program to web application and have selected PHP to use a on the server end along with apache and firebird rdms. As developing a web application is much different...
8
by: S.Marion | last post by:
Hello, We are interested in programmers' experiences of programming languages supported by managed runtimes (including but not limited to Java, C#, etc). In particular, we are interested in bugs...
0
by: Kenzo Fong | last post by:
Hi everyone, Sorry to fill up this newsgroup with this request, but for coursework at Erasmus University (the Netherlands) I need to conduct a survey regarding the use of certain open source...
1
by: Nico Baumgarten | last post by:
Dear Madam/Sir, You are invited to participate in an international research study. This research project is headed and led by Cambridge student Nico Baumgarten. What is it all about? It is a...
1
by: Dave | last post by:
I am looking for a JavaScript poll/survey script that meets the following criteria: 1) Just a large number of Yes/No questions (at least 20) 2) "Repeat vote-proof" 3) "Display Results" button...
4
by: sara | last post by:
I posted this and got a suggestion that didn't work, so I'm trying again. I am trying to use Duane Hookum's survey database. I am still new at all this, and doing ok, but having a problem. ...
12
by: pietlinden | last post by:
Hi, sorry for the vague subject. I am working for a company that finds respondents for surveys and then sends the respondent list and the survey to another company to perform the actual surveys. ...
7
by: University Student | last post by:
Hi, As part of a small research paper I am writing for a Web Technologies module making up part of my university degree, I am conducting a brief survey to gauge what active users of PHP think of...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.