Solved

MS Access Compound Query

Posted on 2014-03-16
2
674 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 37

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

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

724 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