<?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: Non-correlated and Correlated subqueries in Advanced Programming</title>
    <link>https://communities.sas.com/t5/Advanced-Programming/Non-correlated-and-Correlated-subqueries/m-p/722431#M74</link>
    <description>Interesting. I couldn't come up with an example for an uncorrelated subquery that uses the EXIST operator. Which made me question the definitions again hence the post.</description>
    <pubDate>Sun, 28 Feb 2021 16:38:18 GMT</pubDate>
    <dc:creator>spandya</dc:creator>
    <dc:date>2021-02-28T16:38:18Z</dc:date>
    <item>
      <title>Non-correlated and Correlated subqueries</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Non-correlated-and-Correlated-subqueries/m-p/722360#M70</link>
      <description>&lt;P&gt;The Advanced Programming prep guide distinguishes correlated and non-correlated subqueries with the following definitions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;A noncorrelated subquery is a self-contained subquery that executes independently of the outer query. The simplest type of subquery is a noncorrelated subquery that returns a single value. &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;correlated -&amp;nbsp; A dependent subquery is one that requires one or more values to be passed to it by the outer query before the subquery can return a value to the outer query.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Later on, however, they mention the following SQL query being a correlated subquery but how can that be? How is the subquery in this case dependent on the outer query?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;The following PROC SQL query accomplishes this task by using a correlated subquery and the NOT EXISTS operator. &lt;/EM&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql; &lt;BR /&gt;select lastname, firstname
from certadv.flightattendants &lt;BR /&gt;where not exists &lt;BR /&gt;(select * from certadv.flightschedule where&lt;BR /&gt; flightattendants.empid= flightschedule.empid);
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Feb 2021 21:32:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Non-correlated-and-Correlated-subqueries/m-p/722360#M70</guid>
      <dc:creator>spandya</dc:creator>
      <dc:date>2021-02-27T21:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: Non-correlated and Correlated subqueries</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Non-correlated-and-Correlated-subqueries/m-p/722363#M71</link>
      <description>&lt;P&gt;Because &lt;EM&gt;flightattendants.empid&lt;/EM&gt; is defined outside of the subquery (i.e. in the main query).&lt;/P&gt;</description>
      <pubDate>Sat, 27 Feb 2021 22:03:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Non-correlated-and-Correlated-subqueries/m-p/722363#M71</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2021-02-27T22:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: Non-correlated and Correlated subqueries</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Non-correlated-and-Correlated-subqueries/m-p/722381#M72</link>
      <description>In other words its because the certadv.flightattendants is in the outer query? If it was replaced with another dataset instead (that also had the empID variable) and the subquery was kept the same, would it become non-correlated?</description>
      <pubDate>Sun, 28 Feb 2021 02:21:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Non-correlated-and-Correlated-subqueries/m-p/722381#M72</guid>
      <dc:creator>spandya</dc:creator>
      <dc:date>2021-02-28T02:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: Non-correlated and Correlated subqueries</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Non-correlated-and-Correlated-subqueries/m-p/722387#M73</link>
      <description>&lt;P&gt;If the subquery was uncorrelated it could only refer to variables from datasets mentioned in its FROM clause. It's hard to imagine a case where an EXISTS operator would refer to an uncorrelated subquery.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Feb 2021 04:38:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Non-correlated-and-Correlated-subqueries/m-p/722387#M73</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2021-02-28T04:38:28Z</dc:date>
    </item>
    <item>
      <title>Re: Non-correlated and Correlated subqueries</title>
      <link>https://communities.sas.com/t5/Advanced-Programming/Non-correlated-and-Correlated-subqueries/m-p/722431#M74</link>
      <description>Interesting. I couldn't come up with an example for an uncorrelated subquery that uses the EXIST operator. Which made me question the definitions again hence the post.</description>
      <pubDate>Sun, 28 Feb 2021 16:38:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Advanced-Programming/Non-correlated-and-Correlated-subqueries/m-p/722431#M74</guid>
      <dc:creator>spandya</dc:creator>
      <dc:date>2021-02-28T16:38:18Z</dc:date>
    </item>
  </channel>
</rss>

