Skip to content
Advertisement

Combine the results of multiple queries into one table

I have a table that gets its entries populated through a form in MS Access 2013. I have attached an image of part of the table below. Using the StartTime entry, I created a query that displays all the transactions that occur between 8AM – 9AM, and another query to display all the transactions that occur between 9AM – 10AM, and so on. The problem is that I have so many queries. Is there a way to combine the statements in all the queries into one sql statement and ouput the result in one datasheet with column headings ‘8AM-9AM’, ‘9AM-10AM’, ’10AM-11AM’ and so on. Thank You.

Query example:

Main Table

Query Result 8 AM to 9 AM

Advertisement

Answer

Here’s what I did that may help you or at least get you started. I created queries for each hour that you want output for (8-9, 9-10, 10-11, etc.). Then I created a final query which uses UNION for all of the queries.

Example of your queries that you probably already have:

Second:

And so on…

Exapmle of final query:

Note: I had to create a blank 1st row in order for it to properly name the column on my machine. Not sure if you would have the same problem.

EDIT: Possibly a simpler way only using one table:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement