Union Query?

P

pon

I have two queries QRY_CURR with the Curr_yr_bal, account, account type and
QRY_PRIOR with Prior_yr_bal, account, account type.
I want to create a report or a query with difference between Curr_yr_bal and
Prior_Yr_balance, But not all the account in QRY_CURR_YR is in QRY_PRIOR_YR
and viceversa.
Iam not sure what query to use or how to proceed.
Please help.
Thank you
Pon
 
K

KARL DEWEY

Create a union query with just the Account to build an Account list. Then
left join the list to the othe table.
Then create a union query something like this ---
SELECT Products_all.Product, Products.[Product Name], Products.Vendor,
Products.Amount, Products.ProdDate
FROM Products_all LEFT JOIN Products ON Products_all.Product =
Products.Product
UNION SELECT Products_all.Product, Products.[Product Name], Products.Vendor,
Products.Amount, Products.ProdDate
FROM Products_all LEFT JOIN Products ON Products_all.Product =
Products.Product;
 
P

pon

Thank you very much. With your idea I created this union Query below and got
the data the way I wanted .
I appreciate your help.
Thank you
PON
UNION QUERY

SELECT QRY_CF_SUMMARY_CURR_YR.FUND, QRY_CF_SUMMARY_CURR_YR.ACCT,
QRY_CF_SUMMARY_CURR_YR.TITLE, QRY_CF_SUMMARY_CURR_YR.RUCL,
QRY_CF_SUMMARY_CURR_YR.RUCL_TITLE, QRY_CF_SUMMARY_CURR_YR.CURR_YR_BAL,
QRY_CF_SUMMARY_CURR_YR.Param_Curr_Begin_date,
QRY_CF_SUMMARY_CURR_YR.Param_Curr_end_date, QRY_CF_SUMMARY_PRIOR_YR.FUND,
QRY_CF_SUMMARY_PRIOR_YR.ACCT, QRY_CF_SUMMARY_PRIOR_YR.TITLE,
QRY_CF_SUMMARY_PRIOR_YR.RUCL, QRY_CF_SUMMARY_PRIOR_YR.RUCL_TITLE,
QRY_CF_SUMMARY_PRIOR_YR.PRIOR_YR_BAL,
QRY_CF_SUMMARY_PRIOR_YR.Param_Prior_Begin_date,
QRY_CF_SUMMARY_PRIOR_YR.Param_prior_end_date
FROM QRY_CF_SUMMARY_PRIOR_YR LEFT JOIN QRY_CF_SUMMARY_CURR_YR ON
(QRY_CF_SUMMARY_PRIOR_YR.RUCL = QRY_CF_SUMMARY_CURR_YR.RUCL) AND
(QRY_CF_SUMMARY_PRIOR_YR.ACCT = QRY_CF_SUMMARY_CURR_YR.ACCT);
UNION ALL SELECT QRY_CF_SUMMARY_CURR_YR.FUND, QRY_CF_SUMMARY_CURR_YR.ACCT,
QRY_CF_SUMMARY_CURR_YR.TITLE, QRY_CF_SUMMARY_CURR_YR.RUCL,
QRY_CF_SUMMARY_CURR_YR.RUCL_TITLE, QRY_CF_SUMMARY_CURR_YR.CURR_YR_BAL,
QRY_CF_SUMMARY_CURR_YR.Param_Curr_Begin_date,
QRY_CF_SUMMARY_CURR_YR.Param_Curr_end_date,
null, null, null, null, null, null, null, null
FROM QRY_CF_SUMMARY_CURR_YR LEFT JOIN QRY_CF_SUMMARY_PRIOR_YR ON(
QRY_CF_SUMMARY_CURR_YR.RUCL = QRY_CF_SUMMARY_PRIOR_YR.RUCL) AND
(QRY_CF_SUMMARY_CURR_YR.ACCT = QRY_CF_SUMMARY_PRIOR_YR.ACCT)
WHERE ((((QRY_CF_SUMMARY_PRIOR_YR.RUCL) Is Null) OR(
(QRY_CF_SUMMARY_PRIOR_YR.ACCT) Is Null)));


KARL DEWEY said:
Create a union query with just the Account to build an Account list. Then
left join the list to the othe table.
Then create a union query something like this ---
SELECT Products_all.Product, Products.[Product Name], Products.Vendor,
Products.Amount, Products.ProdDate
FROM Products_all LEFT JOIN Products ON Products_all.Product =
Products.Product
UNION SELECT Products_all.Product, Products.[Product Name], Products.Vendor,
Products.Amount, Products.ProdDate
FROM Products_all LEFT JOIN Products ON Products_all.Product =
Products.Product;

--
KARL DEWEY
Build a little - Test a little


pon said:
I have two queries QRY_CURR with the Curr_yr_bal, account, account type and
QRY_PRIOR with Prior_yr_bal, account, account type.
I want to create a report or a query with difference between Curr_yr_bal and
Prior_Yr_balance, But not all the account in QRY_CURR_YR is in QRY_PRIOR_YR
and viceversa.
Iam not sure what query to use or how to proceed.
Please help.
Thank you
Pon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top