Sql Code Help for Access (urgent help needed)

  • Thread starter Thread starter sallen
  • Start date Start date
S

sallen

I want to add the code below to a query so that only accounts show up
on a report that have a balance greater than the sumprincpmts field.
This query will need to sum the Transactions before comparing to the
sumprincpmts field. Below is the code that I have come up with but I
am getting a syntax error. Please help...



SELECT a.accountnumber, p.sumprincpmt, SUM(t.accountnumber) AS Total
FROM account a, principalpayments p, transactions t WHERE t.total >
p.sumprincpmt GROUP BY t.accountnumber, p.sumprincpmt;


Thank you in advance for any help or guidance.
 
I want to add the code below to a query so that only accounts show up
on a report that have a balance greater than the sumprincpmts field.
This query will need to sum the Transactions before comparing to the
sumprincpmts field. Below is the code that I have come up with but I
am getting a syntax error. Please help...



SELECT a.accountnumber, p.sumprincpmt, SUM(t.accountnumber) AS Total
FROM account a, principalpayments p, transactions t WHERE t.total >
p.sumprincpmt GROUP BY t.accountnumber, p.sumprincpmt;


Thank you in advance for any help or guidance.


I'm not sure that I follow exactly what you're trying to do here, but I
think the syntax error in the SQL as posted is that you're referring to
t.total, but total is *not* a column in the transactions table, it's a
calculated column in the query. So you could try just 'WHERE total' instead
of 'WHERE t.total'.
 
Not to mention that AccountNumber doesn't sound like a field anyone would
ever want to SUM.
(and would probably throw a type-mismatch error if it was a text field)
 
Back
Top