0

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

Essentially I would like to do (in general terms):

(StoredProcedure [Fields] [parameters]) C 
LEFT JOIN (SELECT [Fields] FROM Table) A 
ON C.KeyID=A.KeyID

OR

SELECT [Fields] 
FROM Table A RIGHT JOIN (StoredProcedure [Fields] [parameters]) C 
ON A.KeyID=C.KeyID

Which I understand should give me the same result.

1 - Stored Procedure Query

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' 

2 - Query

SELECT Name, AccountType FROM Account

I tried the below variations, which did not work:

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

OR

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

Are there any suggestions for doing this without dumping both to temporary tables and joining?

Gwolfe
  • 1

1 Answers1

2

You can make use of MS Access or Excel or temporary tables. Export data of report and tables to Excel sheets and then perform link/join.

Refer: http://qodbc.com/links/2900

Are there any suggestions for doing this without dumping both to temporary tables and joining?

You cannot join a stored procedure and a table thus you will need to get the output sorted locally or in temporary tables.

halfer
  • 19,824
  • 17
  • 99
  • 186
Rajendra Dewani
  • 3,281
  • 3
  • 15
  • 8