I am not sure how to title this question; I've found a way to do this, but I'm wondering if there's a better way. I've developed a database from a survey taken where I work. Many of the questions involved a drop down menu, ie. "How often do you order supplies?" with choices such as once a day, once a week, never, etc.
Now I would like to combine some details of the survey. For example, I would like to query how often employees ask for reimbursements, but ONLY for those employees who ORDER SUPPLIES. In this case, I don't care about how OFTEN they order supplies.
This is how I've done it. Query1, below, simply groups employees who order supplies according to how often they do it, including those that NEVER order supplies:
SELECT Count(*) AS Supplies, tblSurvey.Supplies
FROM tblSurvey
GROUP BY tblSurvey.Supplies
ORDER BY Count(*) DESC;
Query2 eliminates the people who DON'T order supplies. This query seems unnecessary, but I found it was one way I could eventually get a SUM (though I won't discuss that on this post):
SELECT Count(*) AS CountofSupplies, tblSurvey.Supplies, tblSurvey.ID
FROM tblSurvey
GROUP BY tblSurvey.Supplies, tblSurvey.ID
HAVING (((tblSurvey.Supplies) Is Not Null And (tblSurvey.Supplies)<>"Never"))
ORDER BY Count(*) DESC;
Query3 joins Query2 to the survey table, in order to determine HOW OFTEN employees are reimbursed but ONLY for those employees who DO order supplies.
SELECT Count(tblSurvey.Reimburse) AS CountofReimburse,
tblSurvey.Reimburse
FROM tblSurvey INNER JOIN Query2 ON tblSurvey.ID = Query2.ID
GROUP BY tblSurvey.Reimburse;
I find that this works for me, but I'm wondering if there's a better more efficient way to do this that requires less steps? But I may be too much of a novice to do this in any other way. Remember, since I don't care about how often employees order supplies, I've tried to eliminate that grouping, which is why this querying process seems to have extra steps.
thanks!
Now I would like to combine some details of the survey. For example, I would like to query how often employees ask for reimbursements, but ONLY for those employees who ORDER SUPPLIES. In this case, I don't care about how OFTEN they order supplies.
This is how I've done it. Query1, below, simply groups employees who order supplies according to how often they do it, including those that NEVER order supplies:
SELECT Count(*) AS Supplies, tblSurvey.Supplies
FROM tblSurvey
GROUP BY tblSurvey.Supplies
ORDER BY Count(*) DESC;
Query2 eliminates the people who DON'T order supplies. This query seems unnecessary, but I found it was one way I could eventually get a SUM (though I won't discuss that on this post):
SELECT Count(*) AS CountofSupplies, tblSurvey.Supplies, tblSurvey.ID
FROM tblSurvey
GROUP BY tblSurvey.Supplies, tblSurvey.ID
HAVING (((tblSurvey.Supplies) Is Not Null And (tblSurvey.Supplies)<>"Never"))
ORDER BY Count(*) DESC;
Query3 joins Query2 to the survey table, in order to determine HOW OFTEN employees are reimbursed but ONLY for those employees who DO order supplies.
SELECT Count(tblSurvey.Reimburse) AS CountofReimburse,
tblSurvey.Reimburse
FROM tblSurvey INNER JOIN Query2 ON tblSurvey.ID = Query2.ID
GROUP BY tblSurvey.Reimburse;
I find that this works for me, but I'm wondering if there's a better more efficient way to do this that requires less steps? But I may be too much of a novice to do this in any other way. Remember, since I don't care about how often employees order supplies, I've tried to eliminate that grouping, which is why this querying process seems to have extra steps.
thanks!