Previous Page | Next Page

The SQL Procedure

Example 10: Querying an In-Line View


Procedure features:

FROM clause

in-line view

Tables: PROCLIB.STAFF2, PROCLIB.SCHEDULE2, PROCLIB.SUPERV2

This example shows an alternative way to construct the query that is explained in Joining Three Tables by joining one of the tables with the results of an in-line view. The example also shows how to rename columns with an in-line view.


Program

 Note about code
libname proclib 'SAS-library';
 Note about code
options nodate pageno=1 linesize=80 pagesize=60;
 Note about code
proc sql;
   title 'All Flights for Each Supervisor';
   select three.*, v.jobcat
 Note about code
      from (select lname, s.idnum, city, flight, date
               from proclib.schedule2 s, proclib.staff2 t
               where s.idnum=t.idnum)
 Note about code
                as three (Surname, Emp_ID, Hometown, 
                           FlightNumber, FlightDate),
 Note about code
      proclib.superv2 v
      where three.Emp_ID=v.supid;

Output: Listing

                        All Flights for Each Supervisor                        1

                                                                      Job
  Surname          Emp_ID  Hometown         FlightNumber  FlightDate  Category
  ----------------------------------------------------------------------------
  MARSHBURN        1106    STAMFORD         579              05MAR94  PT      
  DENNIS           1118    NEW YORK         132              01MAR94  PT      
  DENNIS           1118    NEW YORK         271              04MAR94  PT      
  KIMANI           1126    NEW YORK         579              05MAR94  TA      
  TUCKER           1882    NEW YORK         622              03MAR94  ME      

Previous Page | Next Page | Top of Page