General discussion

Locked

how to combine records of two Queries?

By Hunterzh ·
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.

This conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by DKlippert In reply to how to combine records of ...

Create a third Query that extracts the information you need from your first two.

Collapse -

by IT_Cowboy In reply to how to combine records of ...

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!

Collapse -

by Hunterzh In reply to

Poster rated this answer.

Collapse -

by Hunterzh In reply to how to combine records of ...

This question was closed by the author

Back to Software Forum
4 total posts (Page 1 of 1)  

Related Discussions

Related Forums