Solved

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

Posted on 2011-09-20
2
171 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 500 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

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…
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
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.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

738 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