Hi Sheri
Off the top of my head (in otherwords - not validated)
And not knowing the field names of the 2 files
I think you may want to look at UNION
With Unionfile as (Select Voucher1 as Vchr, Vendor1 as Vndr, Invoice1 as
INV#, PostDate1 as Postdte
from APOHD
union
Select Voucher2 as Vchr, Vendor2 as Vndr, Invoice2 as INV#, PostDate2 as
Postdte from APHHD
select Vchr, Vndr, INV#, Postdte from Unionfile where Vchr = #####
Alan Shore
NBTY, Inc
(631) 244-2000 ext. 5019
AShore@xxxxxxxx
"If you're going through Hell, keep going" - Winston Churchill
"Rowe, Sheri"
<srowe@xxxxxxxxx>
Sent by: To
rpg400-l-bounces@ <RPG400-L@xxxxxxxxxxxx>
midrange.com cc
Subject
02/26/2008 04:32 can this be done with SQL - a
PM record is one file or the other
Please respond to
RPG programming
on the AS400 /
iSeries
<rpg400-l@midrang
e.com>
Hi iSeries Guru's,
Can anyone tell me if I can do this with SQL and if so how?
I have a Vendor File APOHD and a Vendor History file APHHD. A voucher
will either be in one file or the other, not both, as once a voucher is
closed it will be in the History file. Both files contain the same
information, but have different field names.
A user wants to get the Voucher, Vendor#, Invoice# and Posting Date of a
given voucher (it needs to be a variable which I can pass), but it will
be in only one file or the other. I can't figure out how to do a
'non join' on the files.
I know I could do this with 2 separate SQL's, but was curious if it's
possible to do it with one.
I want a result that looks like this, regardless of which file has the
voucher.
Voucher Vendor Invoice Posting Date
79993 1234 456789 080228
Thanks in advance for your help!
Sheri
--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at
http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.