Solved

MS Access Compound Query

Posted on 2014-03-16
2
653 Views
Last Modified: 2014-04-01
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
Comment
Question by:chaddcarr
[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 Comments
 

Author Comment

by:chaddcarr
ID: 39933008
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
 
LVL 36

Accepted Solution

by:
PatHartman earned 100 total points
ID: 39933031
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

696 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