AndrewWolford
MIS
On 4/5 WildHare suggested the following SQL statement in answer to my thread "reading in an access table using the code builder" to get an average age by account:
SELECT Account, Avg(Age)
WHERE balance>0
GROUP BY Account;
First, thanks for the help. Secondly, I have a follow-up question... This pretty much works, however I've run into a small problem which I believe is due to the way the table is laid out. here's what it looks like:
SSN AGE Acct1Bal Acct2Bal .... Acct19Bal
... 20 100 0 0
... 30 0 100 0
... 40 0 0 100
and so on....
My SQL statement looks like this:
SELECT Ave(Age) FROM Accounts WHERE Acct1Bal>0;
this returns the ave age for account1, which is great but I'll have to make 19 queries (1 for each account) doing it this way. Is there a way to get all the ave. ages for each account in 1 query? I don't think I can use a GROUP BY Account since 'Account' and 'balance' aren't seperate. I realize this is a pretty poor table layout, but can it be done? THanks!
-Andrew
SELECT Account, Avg(Age)
WHERE balance>0
GROUP BY Account;
First, thanks for the help. Secondly, I have a follow-up question... This pretty much works, however I've run into a small problem which I believe is due to the way the table is laid out. here's what it looks like:
SSN AGE Acct1Bal Acct2Bal .... Acct19Bal
... 20 100 0 0
... 30 0 100 0
... 40 0 0 100
and so on....
My SQL statement looks like this:
SELECT Ave(Age) FROM Accounts WHERE Acct1Bal>0;
this returns the ave age for account1, which is great but I'll have to make 19 queries (1 for each account) doing it this way. Is there a way to get all the ave. ages for each account in 1 query? I don't think I can use a GROUP BY Account since 'Account' and 'balance' aren't seperate. I realize this is a pretty poor table layout, but can it be done? THanks!
-Andrew