J
Jesterhoz
Hello All,
I have a table, "All", that gets updated with data from two sources, "Some"
and "Other". I am currently querying "All" to get invoice data for a form.
However, if "All" is not updated on a regular basis, then valid invoices are
not in "All" but are in "Some". I hope this makes sense. What I would like
to essentially do is query "All" as well as "Some" but only return unique
records. The problem is that most invoices are in both tables. Also, there
can be multiple valid occurrences of the same invoice number for different
customers or dates. I know this complicates things but it's out of my
control.
Here is an example of some valid info:
InvNo 123456
CustNo 456
InvDate 1/1/05
InvAmt $23.56
InvNo 123456
CustNo 893
InvDate 8/4/04
InvAmt $2,563.45
The first one, for instance, came in through "Some" and has not yet been
added to "All". I want to still have it come up as a result of the query.
However, if it had been added to "All", I don't want it to show up twice on
the form. Here is the SQL statement that I have so far. It does, however,
return data twice if it appears in both tables.
SELECT InvNo, InvDate, CustCode, InvAmt, Route FROM Invoice1 UNION SELECT
InvNo, InvDate, CustCode, InvAmt, Route
FROM GetAllData;
Any help would be much appreciated.
Thanks,
Trevor
I have a table, "All", that gets updated with data from two sources, "Some"
and "Other". I am currently querying "All" to get invoice data for a form.
However, if "All" is not updated on a regular basis, then valid invoices are
not in "All" but are in "Some". I hope this makes sense. What I would like
to essentially do is query "All" as well as "Some" but only return unique
records. The problem is that most invoices are in both tables. Also, there
can be multiple valid occurrences of the same invoice number for different
customers or dates. I know this complicates things but it's out of my
control.
Here is an example of some valid info:
InvNo 123456
CustNo 456
InvDate 1/1/05
InvAmt $23.56
InvNo 123456
CustNo 893
InvDate 8/4/04
InvAmt $2,563.45
The first one, for instance, came in through "Some" and has not yet been
added to "All". I want to still have it come up as a result of the query.
However, if it had been added to "All", I don't want it to show up twice on
the form. Here is the SQL statement that I have so far. It does, however,
return data twice if it appears in both tables.
SELECT InvNo, InvDate, CustCode, InvAmt, Route FROM Invoice1 UNION SELECT
InvNo, InvDate, CustCode, InvAmt, Route
FROM GetAllData;
Any help would be much appreciated.
Thanks,
Trevor