Chapter Contents

Previous

Next
The SQL Procedure

Example 9: Joining Three Tables


Procedure features:
FROM clause
joined-table component
WHERE clause
Tables: PROCLIB.STAFF2, PROCLIB.SCHEDULE2, PROCLIB.SUPERV2

This example joins three tables and produces a report that contains columns from each table.


Input Tables

PROCLIB.STAFF2 [HTML Output]
 [Listing Output]

PROCLIB.SCHEDULE2 [HTML Output]
 [Listing Output]

PROCLIB.SUPERV2 [HTML Output]
 [Listing Output]


Program

libname proclib 'SAS-data-library';
options nodate pageno=1 linesize=80 pagesize=60;
 Note about code
   proc sql;
title 'All Flights for Each Supervisor';
   select s.IdNum, Lname, City 'Hometown', Jobcat,
          Flight, Date
 Note about code
      from proclib.schedule2 s, proclib.staff2 t, proclib.superv2 v
 Note about code
      where s.idnum=t.idnum and t.idnum=v.supid;     


Output
[HTML Output]  [Listing Output]


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.