13.07.2015 Views

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

852 Querying a DBMS Table 4 Chapter 29title ’Total Salary by Jobcode’;proc sql;select jobcode label=’Jobcode’,sum(salary) as totallabel=’Total <strong>for</strong> Group’<strong>for</strong>mat=dollar11.2from mydblib.payrollgroup by jobcode;quit;Output 29.5Querying a DBMS TableTotal Salary by JobcodeJobcodeTotal <strong>for</strong>GroupBCK $232,148.00FA1 $253,433.00FA2 $447,790.00FA3 $230,537.00ME1 $228,002.00ME2 $498,076.00ME3 $296,875.00NA1 $210,161.00NA2 $157,149.00PT1 $543,264.00PT2 $879,252.00PT3 $21,009.00SCP $128,162.00TA1 $249,492.00TA2 $671,499.00TA3 $476,155.00The next example uses the SQL procedure to query flight in<strong>for</strong>mation from theOracle table Delay. The WHERE clause specifies that only flights to London andFrankfurt are retrieved.libname mydblib oracle user=testuser password=testpass;title ’Flights to London and Frankfurt’;proc sql;select dates <strong>for</strong>mat=datetime9.,dest from mydblib.delaywhere (dest eq "FRA") or(dest eq "LON")order by dest;quit;Note: By default, the DBMS processes both the WHERE clause and the ORDER BYclause <strong>for</strong> optimized per<strong>for</strong>mance. See “Overview of Optimizing Your SQL Usage” onpage 41 <strong>for</strong> more in<strong>for</strong>mation. 4

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!