Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8228869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:36:31+00:00 2026-06-07T16:36:31+00:00

I have the following database design: Answers Table: AnswerID, Answer QuestionAnswers Table: ID, QuestionID,

  • 0

I have the following database design:

Answers Table: AnswerID, Answer
QuestionAnswers Table: ID, QuestionID, AnswerID
CompleteSurvey Table: ID, QuestionAnswersID, RespondantID
Questions Table: QuestionID, Question
Employee Table: EmployeeID, Name

In one of the questions, I have the following answers:

ER Estimate
Company Esitmate
Both ER & Company Estimates
None

The answer of this question will affect two questions. What I want now, is to exclude the employees who selected (None) and then exclude them from number of participants in the other two questions. So how to do that?
Let us assume that we have three questions which are A, B and C. So how am I going to be able to exclude the people who selected (None) as an answer for question A from the number of employees who participated in Question B and C.

I wrote the query that shows me the number of participants in each possible answer for each question and it works well, but how I can improve it to get what I want above:

SELECT     COUNT(DISTINCT dbo.CompleteSurvey.RespondantID) AS [Total Number of Participants], dbo.Answers.Answer, dbo.Questions.Question
FROM         dbo.Questions INNER JOIN
                      dbo.QuestionsAnswers ON dbo.Questions.QuestionID = dbo.QuestionsAnswers.QuestionID INNER JOIN
                      dbo.Answers ON dbo.QuestionsAnswers.AnswerID = dbo.Answers.AnswerID LEFT OUTER JOIN
                      dbo.CompleteSurvey ON dbo.QuestionsAnswers.ID = dbo.CompleteSurvey.QuestionsAnswersID
GROUP BY dbo.Answers.Answer, dbo.Questions.Question

UPDATE 2:

148 Both ER & Company Estimates
102 Company Estimate
22  ER Estimate  
130 None

The number of participants in each possible answer for Question A. Now for Question B, let us assume we have the following answers and number of participants:

22    Answer A
180   Answer B
180   Answer C
20    Answer D

When I applied you query to exclude the people with (None) answer in Question A from the following questions, I got negatives numbers for the all answers in Question B. How it can be like this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:36:33+00:00Added an answer on June 7, 2026 at 4:36 pm

    Perhaps this might work:

    SELECT c.Answer, a.Question, COUNT(DISTINCT d.RespondantID) AS totalcount
    FROM Questions a
    INNER JOIN QuestionAnswers b ON a.QuestionID = b.QuestionID
    INNER JOIN Answers c ON b.AnswerID = c.AnswerID
    LEFT JOIN CompleteSurvey d ON b.ID = d.QuestionAnswersID
    LEFT JOIN
    (
        SELECT DISTINCT RespondantID
        FROM CompleteSurvey
        WHERE QuestionAnswersID IN (<id>, <id>)
    ) e ON d.RespondantID = e.RespondantID
    WHERE e.RespondantID IS NULL
    GROUP BY c.Answer, a.Question
    

    You will have to know beforehand the ID for the question-answer combination you want to exclude, and insert it where it says <id> in the query.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following database design: Employee Table: Username, Name, DivisionCode Division Table: SapCode,
I have the following database design: Employee Table: Username, Name Quiz Table: QuizID, Title,
A noob question. I'm putting together my first database and have the following design
I have the following database design: Employee Table: EmployeeID, Name, OrgCode Department Table: OrgCode,
I have the following database design: Employees Table: EmployeeID, Name, OrgCode Departments Table: OrgCode,
I have the following database design: Employees Table: EmployeeID, Name, OrgCode Departments Table: OrgCode,
I have the following database design question: I have a record that contains the
I have been thinking about database design lately and I have the following question:
I have the following database design: Employee Table: EmployeeID, Name, OrgCode Department Table: OrgCode,
I have the following database design: Employee Table: Username, Name, JobTitle, BadgeNo, IsActive, DivisionCode

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.