title: How can I do a simple join on a subquery?
body: <p>I've been at this for 2 hours and have no idea what the issue is.  Although I have worked a fair amount with SQL, I'm struggling with the idiosyncrasies in Access queries relative to SQL queries when using the ADO ACE connection to query Excel worksheets.  My goal at it's most basic is to do a join with a subquery.  I have simplified the query considerably to display the issue, so please excuse the fact that it wouldn't really make sense to run a query like this.   </p>
  
  <p>The error I keep getting is <code>Syntax Error in From Clause</code>.  The worksheet only has 2 columns, <code>Account Number</code> and <code>Cost</code></p>
  
  <pre><code>Sub stackoverflow()
  
  Dim acctcon As New ADODB.Connection
  Dim acctrec As New ADODB.Recordset
  
  acctcon.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\name\Documents\Book1.xlsx;" &amp; _
                              "Extended Properties=" &amp; Chr(34) &amp; "Excel 12.0 Xml;HDR=YES" &amp; Chr(34) &amp; ";"
  
  acctcon.Open
  
  querystr = "Select [Accounts$].[Account Number], [mm].[Cost] " &amp; _
          "FROM [Accounts$] " &amp; _
          "JOIN (Select [Account Number], [Cost] " &amp; _
              "FROM [Accounts$]) As mm " &amp; _
          "ON [Accounts$].[Account Number] = [mm].[Account Number]"
  
  acctrec.Open querystr, acctcon
  
  'Syntax Error on From Clause
  
  End Sub
  </code></pre>