08-30-2004, 07:38 PM
<div class='sqltop'>SQL</div><div class='sqlmain'>[color=blue;font-weight:bold]SELECT[/color] ch.*, Customers.FirstName AS FirstName, Customers.LastName AS LastName,
SUM(Loan.LoanAmount) AS LoanAmount FROM ChequeHeaders ch
LEFT OUTER JOIN Customers ON Customers.SocialInsuranceNumber=ch.SocialInsuranceNumber
LEFT OUTER JOIN Loans ON ch.SocialInsuranceNumber = Loan.SocialInsuranceNumber
WHERE (Loan.LoanType='NEW' OR Loan.LoanType='REN' or loan.loantype is null) AND ch.ChequeDate='20040827'
GROUP BY ch.SocialInsuranceNumber, ch.ID, ch.Bank, ch.Amount, ch.ChequeDate, ch.Type, ch.Notes, ch.TimeOfStart, ch.TimeOfCompletion, ch.AmountToClient, ch.Charge, ch.ChequeNumber, ch.NSF, ch.NSFDate, ch.NSFCharge, ch.Payor, Customers.FirstName, Customers.LastName
</div>
Can anybody tell me what the hell is wrong with that? I get an error returned that says "Syntax error." and that's all the help it gives me.
SUM(Loan.LoanAmount) AS LoanAmount FROM ChequeHeaders ch
LEFT OUTER JOIN Customers ON Customers.SocialInsuranceNumber=ch.SocialInsuranceNumber
LEFT OUTER JOIN Loans ON ch.SocialInsuranceNumber = Loan.SocialInsuranceNumber
WHERE (Loan.LoanType='NEW' OR Loan.LoanType='REN' or loan.loantype is null) AND ch.ChequeDate='20040827'
GROUP BY ch.SocialInsuranceNumber, ch.ID, ch.Bank, ch.Amount, ch.ChequeDate, ch.Type, ch.Notes, ch.TimeOfStart, ch.TimeOfCompletion, ch.AmountToClient, ch.Charge, ch.ChequeNumber, ch.NSF, ch.NSFDate, ch.NSFCharge, ch.Payor, Customers.FirstName, Customers.LastName
</div>
Can anybody tell me what the hell is wrong with that? I get an error returned that says "Syntax error." and that's all the help it gives me.

