By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,456 Members | 1,505 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,456 IT Pros & Developers. It's quick & easy.

SubQuery problem

P: n/a
Hi,

I am having problem getting desired results from the second part of the
query with a subquery. My query looks like this.
SELECT tblSurveyResponse.SurveyID, tblSurveyResponse.SurveyEditionID,
tblSurveyResponse.QuestionID
FROM LkupQuestions INNER JOIN tblSurveyResponse ON
LkupQuestions.QuestionID = tblSurveyResponse.QuestionID
GROUP BY tblSurveyResponse.SurveyID, tblSurveyResponse.SurveyEditionID,
tblSurveyResponse.QuestionID
HAVING (((tblSurveyResponse.SurveyID) In (Select S.SurveyID from
tblSurvey S inner join tblSurveyEditions SE on S.SurveyID =
se.SurveyID group by S.SurveyID having Count(*) 1 )));
This part works fine. This gives me a result set that looks like this.
Survey SurveyEdition Question SurveyResponse
1 1 1 1
1 2 1 2
2 1 1 7
2 2 2 3
>From this result set I want to pick up the questions that exits in more
than one survey edition for a given survey. In this case it would Be
Question 1 and Survey 1 since Question 1 exists in both the editions of
Survey 1.
I donot seem to create a query that will retrieve this result set.

Any help would be appreciated.

Sep 7 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Kaur,

Try a Group by query on your last query results, where you will set
Survey, Survey Edition and Question to "Group By". Then add one of
those fields again and set it to "Count". Filter the field set to
Count to >1 and you should have the results you want.

Regards,
Jerry Chase

Sep 7 '06 #2

P: n/a

jr*****@prodigy.net wrote:
Kaur,

Try a Group by query on your last query results, where you will set
Survey, Survey Edition and Question to "Group By". Then add one of
those fields again and set it to "Count". Filter the field set to
Count to >1 and you should have the results you want.

Regards,
Jerry Chase
Thanks Jerry, that worked. I was trying to do all of it in one query
with subqueries. I guess I have to create two queries in order to
achieve above results.

Kaur

Sep 8 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.