Sql Code Help for Access (urgent help needed)

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.
 
B

Brendan Reynolds

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'.
 
G

George Nicholson

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top