473,508 Members | 2,303 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SubQuery problem

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
2 1469
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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2336
by: Maarten | last post by:
I've the following problem: Table1 serie | dir Table2 serie | user I am making a webpage in php to administrate the values in the db. What I want is that I select all series...
7
9184
by: Andrew Mayo | last post by:
Here's a really weird one for any SQL Server gurus out there... We have observed (SQL Server 2000) scenarios where a stored procedure which (a) begins a transaction (b) inserts some rows into...
8
19568
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a...
7
2358
by: K. Crothers | last post by:
I administer a mechanical engineering database. I need to build a query which uses the results from a subquery as its input or criterion. I am attempting to find all of the component parts of...
5
6572
by: Rod | last post by:
I have a client site where the code below has been working happily for at least four months. The site is using SQL Server 7. The code is ASP.NET Last week an error appeared related to the...
3
3507
by: laurentc via AccessMonster.com | last post by:
Hi. I have an issue with my Access project. I have rather big tables of data (about 11 000 rows). These tables are historical product quotations, so they are very simple : - MyDate...
1
1485
by: Docster2005 | last post by:
Hi folks, A DTS package we have run for years now no longer works. The specific part that is not working is a subquery in the SOURCE object of a transformation. The source is based on a...
13
3807
by: ThePrinceIsRight | last post by:
I have a problem with using a subquery in MS Access. The purpose of the sub-query is to create a list of people who have had doctor exams in the past 6 months and exclude them from the main query....
1
2064
by: mipo1984 | last post by:
I have subquery into a principal query, and i need the subquery return me only the last row of all results, but i can`t use "order by <field> desc " in the subquery because this return me an error,...
1
7717
NeoPa
by: NeoPa | last post by:
Access QueryDefs Mis-save Subquery SQL Access stores its SQL for Subqueries in a strange manner :s It seems to replace the parentheses "()"with square brackets "" and (often) add an extraneous...
0
7224
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
7120
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
7323
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,...
1
7039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7494
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...
1
5050
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4706
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...
0
1553
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.