Discussion Locked

how to combine records of two Queries?

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I'm designing a database calculating salary in a company. In order to make calculation, I have to design Queries.

One item in the Query is Personal Income Tax. There are two categories: for local people, Tax is (Sum minus 880), then further calculation; for foreign people, Tax is (Sum minus 4000), then same further calculation.

I've tried to design a IIF function, but failed. So have to make two Queries. They have exactly same items, but with different formula.

And now I need to combine the records of the two Queries. Then how to do it?

Append Query is just for table, not for existing Queries.

4 replies

by it_cowboy

If I understand your question correctly, You need to create a union query. One condition of a Union query is that the field names of the two queries you want to join must be identical.
- Create a blank query
- Copy and paste the SQL from your first query into the new query
- Remove the semi colon from the end of the SQL statement
- Copy and paste the SQL from your second query into the new query underneath the first query SQL.
Precede the SELECT statement for the second query with "UNION "
For example:
SQL for new query will look like:
SELECT .....
UNION SELECT ....

Good luck!

This discussion is closed to new replies.