[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 782
  • Last Modified:

MS Access Compound Query

Within an MS Access database, I need to filter for unique values in a single table and then produce a count for how many times each of those unique values appeared in the table.

The end goal is a single form in datasheet view that lists each unique value, its current record count, and the target sample size.  I can then apply the appropriate conditional formatting.

I have two tables.  

"table_questions" simply lists all the various questions ('question') in a survey and a number ('sample_size') representing the ideal sample size

"table_reponses" recorded responses to each survey question. The two columns are 'question' and "response'

So basically, I want to create a form in datasheet view that lists the unique questions in the "table_responses" table, count and report each time that question was in the table, and compare that number to the "sample_size" using the "question" as the primary key.

Any thoughts?
0
chaddcarr
Asked:
chaddcarr
1 Solution
 
chaddcarrAuthor Commented:
As an update, I figured out how to filter for distinct questions only, and produce a count for each:

SELECT
    Question
  , COUNT(*) AS count_distinct_questions
FROM
    ( SELECT DISTINCT
          Question
      FROM tbl_question_count
    ) AS tmp
GROUP BY
    Question;

Now I need to use the Question to query the table_questions table to get the targeted sample size...
0
 
PatHartmanCommented:
Select question, Count(*) As Response_count, sample_size
From table_questions Left Join table_Responses On table_questions.Question = table_Responses.Question
Group by question, sample_size;

This query should get both of the numbers you need.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now