title: How to join results of stored procedures (ODBC, VBA, Quickbooks, QODBC)
body: <p>I'm trying to join the results of a stored procedure available through the QODBC driver and a table also available through the QODBC driver</p>
  
  <p>Essentially I would like to do (in general terms):</p>
  
  <pre><code>(StoredProcedure [Fields] [parameters]) C 
  LEFT JOIN (SELECT [Fields] FROM Table) A 
  ON C.KeyID=A.KeyID
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>SELECT [Fields] 
  FROM Table A RIGHT JOIN (StoredProcedure [Fields] [parameters]) C 
  ON A.KeyID=C.KeyID
  </code></pre>
  
  <p>Which I understand should give me the same result.</p>
  
  <p>1 - Stored Procedure Query</p>
  
  <pre><code>sp_report CustomSummary show Label, RowData, LabelAccountName, 
  Amount, NumColTitleRows, RowType, ReportSubtitle parameters 
  DateMacro='LastYear', SummarizeRowsBy = 'Account', 
  SummarizeColumnsBy = 'Month', Calendar = 'FiscalYear', 
  ReturnRows = 'All', ReturnColumns = 'All', ReportBasis='Accrual', 
  AccountFilterType='IncomeAndExpense' 
  </code></pre>
  
  <p>2 - Query</p>
  
  <pre><code>SELECT Name, AccountType FROM Account
  </code></pre>
  
  <p>I tried the below variations, which did not work:</p>
  
  <pre><code>SELECT AccountType, * FROM (sp_report CustomSummary show Label, RowData, LabelAccountName, 
  Amount, NumColTitleRows, RowType, ReportSubtitle parameters DateMacro='LastYear', 
  SummarizeRowsBy = 'Account', SummarizeColumnsBy = 'Month', Calendar = 'FiscalYear', ReturnRows = 'All', 
  ReturnColumns = 'All', ReportBasis='Accrual', AccountFilterType='IncomeAndExpense') C 
  LEFT JOIN (SELECT Name, AccountType FROM Account) A ON C.LabelAccountName = A.Name
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>SELECT Name, AccountType FROM Accounts A RIGHT JOIN (sp_report CustomSummary show 
  Label, RowData, LabelAccountName, Amount, NumColTitleRows, RowType, 
  ReportSubtitle parameters DateMacro='LastYear', SummarizeRowsBy = 'Account', SummarizeColumnsBy = 'Month', 
  Calendar = 'FiscalYear', ReturnRows = 'All', ReturnColumns = 'All', ReportBasis='Accrual', 
  AccountFilterType='IncomeAndExpense') C ON A.Name = C.LabelAccountName
  </code></pre>
  
  <p>Are there any suggestions for doing this without dumping both to temporary tables and joining? </p>