I want to run a select statement that includes a sum from another table. I know I will probably have to setup a join but I'm not sure how to approach it.
I want to select a list of accounts then get their balances(sum from another table) This is the idea I have been going in but obviously its not correct.
SELECT
account_name
FROM
tblaccounts
JOIN (
SELECT
SUM(balance) AS account_balance
FROM
tblinvoices
) t ON t.account_id = tblaccount_account_id
WHERE
tblaccounts.account_id = 1
desired output
Name | balance ------------------ Account1 50 Account2 100