<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Faster way to select top n rows from oracle connection in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Faster-way-to-select-top-n-rows-from-oracle-connection/m-p/522674#M4476</link>
    <description>You can use select top, but it has to be in the inner most query since it's only available in Oracle, not SAS.</description>
    <pubDate>Wed, 19 Dec 2018 18:37:32 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-12-19T18:37:32Z</dc:date>
    <item>
      <title>Faster way to select top n rows from oracle connection</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Faster-way-to-select-top-n-rows-from-oracle-connection/m-p/522673#M4475</link>
      <description>&lt;P&gt;Hi all.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Assume the code below. I am using 'inobs=1000' or 'obs=1000' options on the proc sql statement to select the top 1000 records. Is there a faster way to get the same result? I thought I could use the WHERE or SELECT TOP&amp;nbsp; statement but I getting errors.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;PROC&lt;/STRONG&gt; &lt;STRONG&gt;SQL&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; CONNECT TO ORACLE as&amp;nbsp;EstCon&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (PATH=mypath authdomain=Oracledev);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CREATE TABLE&amp;nbsp;MyTable AS&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SELECT *&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FROM CONNECTION TO &lt;SPAN&gt;EstCon&amp;nbsp;&lt;/SPAN&gt;(&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SELECT&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;t1.ID,&amp;nbsp; t2.name,&amp;nbsp;t3.gender, t4.Age&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FROM Table1 t1&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; INNER JOIN&amp;nbsp;table2 t2 ON (t1.ID = t2._ID)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; INNER JOIN&amp;nbsp;table3 t6 ON (t1.ID = t3.ID)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; INNER JOIN&amp;nbsp;table4 ON (t1.PARTY_ID = t4.PARTY_ID));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DISCONNECT FROM &lt;SPAN&gt;EstCon&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;QUIT&lt;/STRONG&gt;;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 18:45:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Faster-way-to-select-top-n-rows-from-oracle-connection/m-p/522673#M4475</guid>
      <dc:creator>MikeAAC</dc:creator>
      <dc:date>2018-12-19T18:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: Faster way to select top n rows from oracle connection</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Faster-way-to-select-top-n-rows-from-oracle-connection/m-p/522674#M4476</link>
      <description>You can use select top, but it has to be in the inner most query since it's only available in Oracle, not SAS.</description>
      <pubDate>Wed, 19 Dec 2018 18:37:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Faster-way-to-select-top-n-rows-from-oracle-connection/m-p/522674#M4476</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-19T18:37:32Z</dc:date>
    </item>
    <item>
      <title>Re: Faster way to select top n rows from oracle connection</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Faster-way-to-select-top-n-rows-from-oracle-connection/m-p/522679#M4477</link>
      <description>&lt;P&gt;Thanks Reeza.&lt;/P&gt;&lt;P&gt;I tried it but I got this error msg:&lt;/P&gt;&lt;P&gt;ERROR: ORACLE prepare error: ORA-00923: FROM keyword not found where expected. SQL statement: SELECT TOP 100 * FROM table1 t1 inner join table2 on (t1.ID = t2.ID)...&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 19:12:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Faster-way-to-select-top-n-rows-from-oracle-connection/m-p/522679#M4477</guid>
      <dc:creator>MikeAAC</dc:creator>
      <dc:date>2018-12-19T19:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: Faster way to select top n rows from oracle connection</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Faster-way-to-select-top-n-rows-from-oracle-connection/m-p/522680#M4478</link>
      <description>&lt;P&gt;The most efficient way is to filter the rows in oracle :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;

   CONNECT TO ORACLE as EstCon

    (PATH=mypath authdomain=Oracledev);

            CREATE TABLE MyTable AS

            SELECT *

            FROM CONNECTION TO EstCon (

                 SELECT 
                       t1.ID,  t2.name, t3.gender, t4.Age

                      FROM Table1 t1

                      INNER JOIN table2 t2 ON (t1.ID = t2._ID)

                      INNER JOIN table3 t6 ON (t1.ID = t3.ID)

                      INNER JOIN table4 ON (t1.PARTY_ID = t4.PARTY_ID)
				WHERE rownum  &amp;lt;=1000
);

             DISCONNECT FROM EstCon;

QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the alternate query to filter in sas:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL outobs=1000;

   CONNECT TO ORACLE as EstCon

    (PATH=mypath authdomain=Oracledev);

            CREATE TABLE MyTable(obs=2) AS

            SELECT *

            FROM CONNECTION TO EstCon (

                 SELECT 

                       t1.ID,  t2.name, t3.gender, t4.Age

                      FROM Table1 t1

                      INNER JOIN table2 t2 ON (t1.ID = t2._ID)

                      INNER JOIN table3 t6 ON (t1.ID = t3.ID)

                      INNER JOIN table4 ON (t1.PARTY_ID = t4.PARTY_ID));

             DISCONNECT FROM EstCon;

QUIT;


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 19:17:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Faster-way-to-select-top-n-rows-from-oracle-connection/m-p/522680#M4478</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2018-12-19T19:17:58Z</dc:date>
    </item>
    <item>
      <title>Re: Faster way to select top n rows from oracle connection</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Faster-way-to-select-top-n-rows-from-oracle-connection/m-p/522681#M4479</link>
      <description>&lt;P&gt;May be try this :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;

   CONNECT TO ORACLE as EstCon

    (PATH=mypath authdomain=Oracledev);

            CREATE TABLE MyTable AS

            SELECT *

            FROM CONNECTION TO EstCon (

             SELECT * FROM (   SELECT 
                       t1.ID,  t2.name, t3.gender, t4.Age

                      FROM Table1 t1

                      INNER JOIN table2 t2 ON (t1.ID = t2._ID)

                      INNER JOIN table3 t6 ON (t1.ID = t3.ID)

                      INNER JOIN table4 ON (t1.PARTY_ID = t4.PARTY_ID)) SAMP
				WHERE rownum  &amp;lt;=1000
				ORDER BY rownum
);

             DISCONNECT FROM EstCon;

QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Dec 2018 19:22:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Faster-way-to-select-top-n-rows-from-oracle-connection/m-p/522681#M4479</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2018-12-19T19:22:16Z</dc:date>
    </item>
    <item>
      <title>Re: Faster way to select top n rows from oracle connection</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Faster-way-to-select-top-n-rows-from-oracle-connection/m-p/522682#M4480</link>
      <description>&lt;P&gt;try rownum.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;

   CONNECT TO ORACLE as EstCon

    (PATH=mypath authdomain=Oracledev);

            CREATE TABLE MyTable AS

            SELECT *

            FROM CONNECTION TO EstCon (
          select * from 

               (  SELECT

                       t1.ID,  t2.name, t3.gender, t4.Age

                      FROM Table1 t1

                      INNER JOIN table2 t2 ON (t1.ID = t2._ID)

                      INNER JOIN table3 t6 ON (t1.ID = t3.ID)

                      INNER JOIN table4 ON (t1.PARTY_ID = t4.PARTY_ID))
WHERE ROWNUM &amp;lt;= 1000);

             DISCONNECT FROM EstCon;

QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Dec 2018 19:29:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Faster-way-to-select-top-n-rows-from-oracle-connection/m-p/522682#M4480</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2018-12-19T19:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: Faster way to select top n rows from oracle connection</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Faster-way-to-select-top-n-rows-from-oracle-connection/m-p/522716#M4485</link>
      <description>&lt;P&gt;If you want to limit the results of a query to see the first 1000 where order by matters than you might use a sub-query technique additionally.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SELECT *
FROM (SELECT t1.ID,  t2.name, t3.gender, t4.Age
          FROM Table1 t1
             INNER JOIN table2 t2 ON (t1.ID = t2._ID)
             INNER JOIN table3 t6 ON (t1.ID = t3.ID)
             INNER JOIN table4 ON (t1.PARTY_ID = t4.PARTY_ID)
          Order by t1.PARTY_ID)
			 
WHERE ROWNUM &amp;lt;=1000;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Dec 2018 21:34:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Faster-way-to-select-top-n-rows-from-oracle-connection/m-p/522716#M4485</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-12-19T21:34:08Z</dc:date>
    </item>
  </channel>
</rss>

