SORT-MERGE/XL General User's Guide (32650-90883)
56 Chapter4
Using MERGE/XL Interactively
Merging Files Using Multiple Keys
123456789012345678901234567890123456789012345
1 ADAMS JERROLD INSPECTOR 8044
2 ANDERSON CHARLES PRESIDENT 0247
3 ANDERSON CHARLES SALES REP 3456
4 ANDERSON MARY ACCOUNTANT 6345
5 CARLSON ROBERTA TREASURER 3586
6 CARLSON PETER BUYER 8043
7 CLARK STEVE ASSEMBLER 8046
8 FISHER TOM SHIPPING CLERK 7309
9 JOHNSON FRANCES RECEPTIONIST 7943
10 LANGE ROBERT ENGINEER 3235
11 MATHEWS EDDY PLANNER 8045
12 SMITH HOWARD DESIGNER 6794
13 TAYLOR HEATHER SECRETARY 7272
14 ZIMMER ANDREW ENGINEER 5739
Note that the two CARLSON entries are not listed alphabetically according to their first
names. In case of a tie during a single key merge, the names are listed in the order in
which the system receives them. Since ROBERTA CARLSON appeared in the file EMPLOYEE,
which was the first file designated with the >INPUT command, that entry is listed first in
the merged file. Doing a multiple key merge, as shown below, would arrange these entries
in the proper order.
Merging Files Using Multiple Keys
You can combine files based on more than one key. The files must contain the same data
format, and the key data items must start at the same character position (column) and be
the same length.
To combine EMPLOYEE and NEWHIRES into a new file named COMPANY by last name, first
name, and job title, enter the following sequence of commands:
:MERGE
HP32214A.01.00 MERGE/3000 WED, JUN 3, 1987, 12:15 PM
© HEWLETT-PACKARD CO. 1986
>INPUT EMPLOYEE, NEWHIRES
>OUTPUT COMPANY
>KEY 1, 11; 12, 11; 23, 19
>END
This would arrange the two CARLSON entries in their proper alphabetical order with regard
to their first names. Only the two CARLSON entries are shown in the following example:
:EDITOR