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


Outer join or Union or

Outer join or Union or

Outer join or Union or

This is a cut down version of my problem. I am sure the answer is so simple
I have a sales and budget table
ID Period Sales
1 1 200
2 3 300
3 4 500

ID Period Budget
1 1 100
2 2 400
3 4 50

I would like a query to produce

Peron Sales Budget
1 200 100
2 0 400
3 300 0
4 500 50

Please help

RE: Outer join or Union or

You could first create helper query (union, distinct) to get all existing periods. If it is a fixed set, you can create table with periods instead. Next outer join this query (or table) with sales and budget tables.
Alternatively union sales and budget tables, with adding description column (Sales or Budget). Next create crosstab query. Drawback: nulls instead zeros, poor input for reports and other queries.


RE: Outer join or Union or

I did my phd (piled higher & deeper) on oyher queries.

BTW, GPnew, welcome to Tek-Yips.


glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Outer join or Union or

I love crosstabs but I think you can accomplish this with a UNION and a TOTALS query. Your union query would look like:

CODE --> quniSalesBudget

SELECT Period, SALES, 0 as Budget
FROM Sales
UNION SELECT Period, 0, Budget
FROM Budget 

Then create a totals query:

CODE --> sql

SELECT Period, Sum(Sales) as TotSales, Sum(Budget) as TotBudget
FROM quniSalesBudget
GROUP BY Period 

Hook'D on Access
MS Access MVP 2001-2016

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!

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