×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Combine queries with different items

Combine queries with different items

Combine queries with different items

(OP)
I have one query that contains sales of all items in a date range, and another that contains credits in the same date range.

Almost always the credits are for products for which there are corresponding sales. But sometimes not, where a customer has received credits for products bought earlier than the date range, and there have been no sales of these products in the current date range.

I can use a join type to subtract credits for all products where there have been sales but I'm looking for a way of including the data for credit-only products.

This shows an example of the two queries.


The highlighted credit is without corresponding sale product. The end result I need would start like this but I can only think of complicated ways of getting to this result.

RE: Combine queries with different items

I'm not sure what you are looking for. Do you want to include all sold and credit records if they exist in either list?

Can you share the SQL view of your queries?

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016

RE: Combine queries with different items

How about:

"the credits [...] for products for which there are corresponding sales."
UNION
"products bought earlier than the date range, and there have been no sales of these products in the current date range."
ponder


---- Andy

There is a great need for a sarcasm font.

RE: Combine queries with different items

Slightly expanding Andy's hint:
1. union query qryBeerSoldCreditDutyCalc:
SELECT [Beer Name], [ABV], [Pints] AS [Vol]
FROM
qryBeerSoldDutyCalc
UNION ALL
SELECT [Beer Name], [ABV], -[Pints] AS [Vol]
FROM
qryBeerCreditDutyCalc;

2. aggregate query (sum) from qryBeerSoldCreditDutyCalc

combo

RE: Combine queries with different items

(OP)
Thanks all for quick responses, Andy for the pointer but especially Combo for giving the complete solution, worked a treat. Had forgotten about Union queries, symptom of 8th decade.

Thanks to all too for previous advice on how to submit questions clearly, still learning.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close