Show Account Balance

This commit is contained in:
jacob1123 committed 2021-12-02 21:29:11 +00:00
1 parent 276fdb4ade
commit 6f8a94ff5d
4 files changed
+19 -9

No files matched your search

+4 -2
View File
@@ -5,5 +5,7 @@ VALUES ($1, $2)
RETURNING *;
-- name: GetAccounts :many
SELECT accounts.* FROM accounts
WHERE accounts.budget_id = $1;
SELECT accounts.id, accounts.name, SUM(transactions.amount) as balance FROM accounts
WHERE accounts.budget_id = $1
AND transactions.date < NOW()
GROUP BY accounts.id, accounts.name;