zipforbrains <[email protected]> wrote:
> I have two tables, one with bank accounts, one which holds groupings of those
> accounts, as follows:
> Table Accounts
> aName
> aBalance
> 
> Table GroupMembers
> gName
> aName
> 
> What SQL query would total the account balances (aBalance) for all the
> accounts (aName) associated with each group (gName)?

select gName, sum(aBalance)
from Accounts a join GroupMembers g on (a.aName = g.aName)
group by gName;

-- 
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to