Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script Help

Status
Not open for further replies.

Clarkmeister7

Technical User
Jun 25, 2009
1
GB
I need some help on the following. I have 2 files that I can join to create one set of results. I then need to duplicate this and compare across both sets of results and ideally join with another file.

Details are as follows :

File Name : MGLINE

Fields : MRTRNR, MRRORN, MRITNO, MRTRQT

Data :

410 213 Item1 10
410 213 Item2 20
410 213 Item3 30
411 ___ Item1 10
411 ___ Item2 20
411 ___ Item3 30
412 ___ Item1 20
412 ___ Item2 10
412 ___ Item3 20

File : MGHEAD

Fields : MGTRNR, MGTRTP, MGTRDT, MGTWLO, MGWHLO

Date :

410 R01 280609 ___ 190
411 DR1 150609 190 102
412 DR0 160609 190 102

In the above example I want join MGHEAD and MGLINE on MRTRNR. (I have written the SQL for this no problem)

This should give me a file that looks like :

410 R01 280609 ___ 190 213 Item1 10
410 R01 280609 ___ 190 213 Item2 20
410 R01 280609 ___ 190 213 Item3 30
411 DR1 150609 190 102 ___ Item1 10
411 DR1 150609 190 102 ___ Item2 20
411 DR1 150609 190 102 ___ Item2 30
412 DR0 160609 190 102 ___ Item1 20
412 DR0 160609 190 102 ___ Item2 10
412 DR0 160609 190 102 ___ Item3 20

I need 2 sets of the same data.

I then want to match where a.MGWHSL=b.MGTWLO and a.MRTRTP<>b.MRTRTP and a.MRITNO=b.MRITNO and a.MRTRQT=b.MRTRQT

The result I expect to show is this :

410 R01 280609 411 DR1 150609 213 190 Item1 10
410 R01 280609 411 DR1 150609 213 190 Item2 20
410 R01 280609 411 DR1 150609 213 190 Item3 30

but really all I need is 1 return of

410 R01 280609 411 DR1 150609 213 190

but I can filter out manually if need be. I would ideally like to join this to another file using a join on MGRORN.

Hope this is enough information.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top