bobdole22
08-30-2013, 06:56 PM
Can Excel run this?
SELECT Sum(Data.PBO) AS SumOfPBO, Sum(Data.AccruedInterest) AS SumOfAccruedInterest, Sum(IIf([Status]="Claims" Or [Status]="Forbearance",[AccruedInterest],IIf([Status]="Repayment",0,IIf([SubsidyIndicator]="N",[AccruedInterest],0)))) AS ITBC, Sum(IIf([ABI]=0,0,[pbo]/[ABI])) AS Borr, Count(Data.BorrowerUniqueID) AS Loans, Sum([PBO]*[RemainingRepaymentTerm])/Sum([PBO]) AS RepayTerm, Sum([pbo]*[InterestRate])/Sum([PBO]) AS IntRate
FROM Data LEFT JOIN tbl_ABI ON Data.BorrowerUniqueID = tbl_ABI.BorrowerUniqueID
HAVING (((Data.PBO)<>0));
I just need to know if it's possible because it either returns an error in Select statment syntax or returns zero.
I'm using this:
Set cn = New ADODB.Connection
With cn
.Provider = "Microsoft.ACE.OLEDB.12.0"
.Open MyConn
Set rs = .Execute(sSQL)
End With
Cross-thread: Can Excel run this big SQL? (http://www.vbaexpress.com/forum/showthread.php?47370-Can-Excel-run-this-big-SQL&p=296264#post296264)
SELECT Sum(Data.PBO) AS SumOfPBO, Sum(Data.AccruedInterest) AS SumOfAccruedInterest, Sum(IIf([Status]="Claims" Or [Status]="Forbearance",[AccruedInterest],IIf([Status]="Repayment",0,IIf([SubsidyIndicator]="N",[AccruedInterest],0)))) AS ITBC, Sum(IIf([ABI]=0,0,[pbo]/[ABI])) AS Borr, Count(Data.BorrowerUniqueID) AS Loans, Sum([PBO]*[RemainingRepaymentTerm])/Sum([PBO]) AS RepayTerm, Sum([pbo]*[InterestRate])/Sum([PBO]) AS IntRate
FROM Data LEFT JOIN tbl_ABI ON Data.BorrowerUniqueID = tbl_ABI.BorrowerUniqueID
HAVING (((Data.PBO)<>0));
I just need to know if it's possible because it either returns an error in Select statment syntax or returns zero.
I'm using this:
Set cn = New ADODB.Connection
With cn
.Provider = "Microsoft.ACE.OLEDB.12.0"
.Open MyConn
Set rs = .Execute(sSQL)
End With
Cross-thread: Can Excel run this big SQL? (http://www.vbaexpress.com/forum/showthread.php?47370-Can-Excel-run-this-big-SQL&p=296264#post296264)