如何连接存储过程的结果(ODBC,VBA,Quickbooks,QODBC)

时间:2017-04-27 15:14:48

标签: sql vba odbc quickbooks qodbc

我正在尝试加入通过QODBC驱动程序提供的存储过程的结果以及通过QODBC驱动程序提供的表格

基本上我想做(一般来说):

(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

我理解的应该给我相同的结果。

1 - 存储过程查询

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 - 查询

SELECT Name, AccountType FROM Account

我尝试了以下变体,但没有效果:

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

有没有建议这样做而不将两者都转储到临时表并加入?

1 个答案:

答案 0 :(得分:1)

您可以使用MS Access或Excel或临时表。将报表和表格的数据导出到Excel工作表,然后执行链接/连接。

参考:http://qodbc.com/links/2900

  

有没有建议这样做而不将两者都转储到临时表并加入?

您无法加入存储过程和表,因此您需要在本地或临时表中对输出进行排序。