<?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: Can someone explain this SQL to me in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Can-someone-explain-this-SQL-to-me/m-p/188257#M35590</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I find it puzzling too, The following example generates an error at the missing ON clause:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data a;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;do x = "A", "B", "C"; output; end; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data b;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;do x = "R", "S"; output; end; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data c;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;do x = "1", "2", "S"; output; end; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sql;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select * from a inner join b inner join c on b.x=c.x;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 26 Feb 2014 23:23:06 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2014-02-26T23:23:06Z</dc:date>
    <item>
      <title>Can someone explain this SQL to me</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-someone-explain-this-SQL-to-me/m-p/188256#M35589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I received some rather complicated SQL code from our database group. I input it into SAS PROC SQL properly, and it works. Great! But I don't understand it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I expect to see something like the following constructions in the FROM Clause&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FROM table1 RIGHT JOIN table2 ON table1.lotid=table2.lotid&lt;/P&gt;&lt;P&gt;LEFT JOIN table3 ON table1.historyid=table3.historyid&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I expect to see, and the way I write code, looks like the above. &lt;STRONG&gt;The key point I am making above is that each join has its own ON clause&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But that's not what I see in this working example of SQL&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I see tables being joined with no apparent ON clause in the sequence that I displayed above, note that many joins are done in sequence and only after the third join do I see an ON clause. The code below is a fragment of the entire FROM clause. Please explain this to me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FROM db.StartHistoryDetail RIGHT OUTER JOIN db.Employee Employee_1 INNER JOIN db.Product&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 db.ProductBase ON db.Product.ProductBaseId = db.ProductBase.ProductBaseId&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 db.HistoryMainline INNER JOIN db.Container&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; ON db.HistoryMainline.ContainerId = db.Container.ContainerId&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Feb 2014 20:21:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-someone-explain-this-SQL-to-me/m-p/188256#M35589</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2014-02-26T20:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone explain this SQL to me</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-someone-explain-this-SQL-to-me/m-p/188257#M35590</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I find it puzzling too, The following example generates an error at the missing ON clause:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data a;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;do x = "A", "B", "C"; output; end; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data b;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;do x = "R", "S"; output; end; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data c;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;do x = "1", "2", "S"; output; end; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sql;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select * from a inner join b inner join c on b.x=c.x;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Feb 2014 23:23:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-someone-explain-this-SQL-to-me/m-p/188257#M35590</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-02-26T23:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone explain this SQL to me</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-someone-explain-this-SQL-to-me/m-p/188258#M35591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Paige,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I get an error if I run that code.&amp;nbsp; Can you post the full code that actually ran?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Art&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Feb 2014 23:26:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-someone-explain-this-SQL-to-me/m-p/188258#M35591</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-02-26T23:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone explain this SQL to me</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-someone-explain-this-SQL-to-me/m-p/188259#M35592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My guess is that your query is not run by SAS, it is passed to some other DBMS as a pass-through query. That DBMS could possibly understand the joins without ON clauses as &lt;STRONG&gt;NATURAL&lt;/STRONG&gt; joins. Natural joins have implicit ON clauses that equate all field pairs with corresponding names and types. Going back to my small example, an equivalent SAS/SQL query would be :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data a;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;do x = "A", "B", "R"; a + 1; output; end; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data b;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;do x = "R", "B"; b + 1; output; end; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data c;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;do x = "1", "2", "R"; c + 1; output; end; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sql;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select * from a &lt;SPAN style="color: #800000;"&gt;natural&lt;/SPAN&gt; inner join b inner join c on b.x=c.x;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Feb 2014 03:11:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-someone-explain-this-SQL-to-me/m-p/188259#M35592</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-02-27T03:11:21Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone explain this SQL to me</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-someone-explain-this-SQL-to-me/m-p/188260#M35593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, the SQL is passed to an SQL Server for execution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If, as you are all telling me, that this is not a SAS issue but rasther an issue about how the code works on an SQL Server, I think the best answer for me is to go back to the database group that created the code and see if any of them can explain it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I get an explanation, I will post it here.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Feb 2014 12:52:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-someone-explain-this-SQL-to-me/m-p/188260#M35593</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2014-02-27T12:52:32Z</dc:date>
    </item>
  </channel>
</rss>

