Results 1 to 20 of 24

Thread: Can Excel run this big SQL?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #22
    How about this one:

    sSQL = ""
            'This statement is too long and must be split up below
            
                ReDim s(1 To 9)
                s(1) = "SELECT tbl_ALLStatus.Status, Sum(Data.PBO) AS SumOfPBO,"
                s(2) = " Sum([PBO]/[ABI]) AS Borrs, Sum([PBO])/Sum([pbo]/[abi]) AS Borr_ABI, Count(Data.BorrowerUniqueID) AS Loans,"
                s(3) = " tbl_ALLStatus.StatusOrder, Sum(IIf([LoanTypeName]='Consolidation,[PBO],0)) AS Cons_PBO,"
                s(4) = " Sum(IIf([LoanTypeName]<>'Consolidation',[PBO],0)) AS NonCons_PBO"
                s(5) = "FROM ((Data LEFT JOIN tbl_ALLStatus ON Data.Status = tbl_ALLStatus.Status) LEFT JOIN tbl_ABI"
                s(6) = " ON Data.BorrowerUniqueID = tbl_ABI.BorrowerUniqueID) LEFT JOIN tbl_ALLLoanTypes ON (Data.LoanType = tbl_ALLLoanTypes.LoanType) AND (Data.LoanProgram = tbl_ALLLoanTypes.LoanProgram)"
                s(7) = "WHERE (((Data.PBO)<>0))"
                s(8) = "GROUP BY tbl_ALLStatus.Status, tbl_ALLStatus.StatusOrder"
                s(9) = "ORDER BY tbl_ALLStatus.StatusOrder;"
    
    
                sSQL = Join(s(), vbCrLf)
                'This statement will display qry_Report3
    Getting this Error:
    Syntax...

    It's large so I put it in the attachment

    I really need to figure out how this delimiter works because I have to do 10 of these and I'm only on #3.
    Attached Images Attached Images
    "My common sense is tingling!" - Deadpool
    http://marveldcforum.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •