![](https://pdfstore-manualsonline.prod.a.ki/pdfasset/b/da/bda6fccb-b246-43e7-a520-a01ed647b8cf/bda6fccb-b246-43e7-a520-a01ed647b8cf-bg104.png)
250 Querying Multiple DBMS Tables Chapter 13
where march.flight=delay.flight and
march.dates=delay.dates and
march.flight=internat.flight and
delay>0
order by delay descending;
quit;
Note: By default, SAS/ACCESS passes the entire join to the DBMS for processing in
order to optimize performance. See “Passing Joins to the DBMS” on page 34 for more
information.
Output for this example is shown here.
Output 13.9 Querying Multiple DB2 Tables
Delayed International Flights in March
FLIGHT DATES DELAY
------------------------
622 04MAR1998 30
219 06MAR1998 27
622 07MAR1998 21
219 01MAR1998 18
219 02MAR1998 18
219 07MAR1998 15
132 01MAR1998 14
132 06MAR1998 7
132 03MAR1998 6
271 01MAR1998 5
132 02MAR1998 5
271 04MAR1998 5
271 05MAR1998 5
271 02MAR1998 4
219 03MAR1998 4
271 07MAR1998 4
219 04MAR1998 3
132 05MAR1998 3
219 05MAR1998 3
271 03MAR1998 2
The next example uses the SQL procedure to retrieve the combined results of two
queries to the Oracle tables Payroll and Payroll2. An OUTER UNION in PROC SQL
concatenates the data.
libname mydblib oracle user=testuser password=testpass;
title "Payrolls 1 & 2";
proc sql;
select idnum, sex, jobcode, salary,
birth format datetime9., hired format datetime9.
from mydblib.payroll
outer union corr
select *
from mydblib.payroll2
order by idnum, jobcode, salary;
quit;
Partial output for this example is shown here.