Solved

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

Posted on 2011-09-20
2
166 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
  • 2
2 Comments
 
LVL 32

Expert Comment

by:ewangoya
Comment Utility

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:
ewangoya earned 500 total points
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now