combining 2 queries into 1

  • Thread starter Thread starter red6000
  • Start date Start date
R

red6000

Hi, Is it possible to write code so that 1 query gives the same as the 2
seperate queries below, thanks:

SELECT QuestionData.Question, Count(QuestionData.Question) AS
Number_of_Times_Asked
FROM QuestionData
GROUP BY QuestionData.Question
ORDER BY Count(QuestionData.Question) DESC;
=======================
SELECT QuestionData.Rootcause, Count(QuestionData.Rootcause) AS
Number_of_Rootcause
FROM QuestionData
GROUP BY QuestionData.Rootcause
ORDER BY Count(QuestionData.Rootcause) DESC;


I ultimately want 1 report to show the data from the above (and other
queries). I have tried the subreport tool, but that just really wasn't
working out for me so i'm trying a different approach.

Thanks.
 
You can use a UNION query to combine data from 2 sources, e.g.:

SELECT QuestionData.Question AS TheTopic,
Count(QuestionData.Question) AS TheCount,
"Question" AS TheType
FROM QuestionData
GROUP BY QuestionData.Question
UNION ALL
SELECT QuestionData.Rootcause AS TheTopic,
Count(QuestionData.Rootcause) AS TheCount,
"RootCause" AS TheType
FROM QuestionData
GROUP BY QuestionData.Rootcause
ORDER BY TheCount DESC;

UNION queries cannot be displayed graphically, and are not updatable.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top