Performing Queries Using SQL |
Querying Multiple Tables
|
Ordering Rows
The ORDER BY clause within the following SELECT statement sorts rows from both tables by values of selected columns. |
proc sql; select bldginfo.id,lastname,bldg,rm,ext from emplib.payroll,emplib.bldginfo where bldginfo.id=payroll.id order by lastname; |
The output below shows rows ordered by LastName . |
ID | LastName | Bldg | Rm | Ext |
1002 | BOWMAN | B | 34 | 2782 |
1007 | BROWN | A | 48 | 0342 |
1049 | FERNANDEZ | D | 22 | 1347 |
1006 | GARRETT | D | 16 | 2209 |
1077 | GIBSON | B | 17 | 1697 |
1008 | HERNAND | A | 19 | 6391 |
1009 | JONES | C | 24 | 3857 |
1005 | KNAPP | B | 98 | 5917 |
1004 | KNIGHT | C | 13 | 6718 |
1074 | MILLSAP | C | 56 | 1543 |
1012 | QUINTERO | B | 30 | 7518 |
1003 | SALAZAR | A | 65 | 2771 |
1083 | SAVAGE | A | 22 | 7357 |
1015 | SCHOLL | C | 49 | 3756 |
1010 | SMITH | B | 37 | 2134 |
1011 | VAN HOTTEN | A | 51 | 2649 |
1017 | WAGGONNER | C | 26 | 2719 |
1001 | WATERHOUSE | A | 57 | 2345 |
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.