?
Solved

SQL: Find missing questions (in a group) in the answers table

Posted on 2011-09-20
2
Medium Priority
?
175 Views
Last Modified: 2012-05-12
I have a questions table with questions that are grouped together.

20 questions belong to group 1
25 questions belong to group 2
18 questions belong to group 3

QuestionID(unique), QuestionGroup, Question

I need to find the questions in each group that are missing in the answers table

QuestionID, UserID, QuestionAnswer

The question I need to answer is: Which questions did the user  NOT answer in each question group. This is indicated by the missing rows in the answers table.

Thanks in advance for any help you can give
0
Comment
Question by:AWEInCA
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 36570673

select QuestionID, Question
from Questiontable
where not exists(select 1 from AnswerTable
                            where AnswerTable.QuestionID = QuestionTable.QuestionID
                            and UserID = 'User you are searching')
0
 
LVL 32

Accepted Solution

by:
Ephraim Wangoya earned 2000 total points
ID: 36570677
select QuestionID, QuestionGroup, Question
from Questiontable
where not exists(select 1 from AnswerTable
                            where AnswerTable.QuestionID = QuestionTable.QuestionID
                            and UserID = 'User you are searching')
order by QuestionGroup, QuestionID
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question