Display accounts sorted by name

This commit is contained in:
2021-12-06 20:47:47 +00:00
parent 2caaa1a048
commit 29cee46a14
2 changed files with 6 additions and 2 deletions

View File

@ -10,7 +10,8 @@ WHERE accounts.id = $1;
-- name: GetAccounts :many
SELECT accounts.* FROM accounts
WHERE accounts.budget_id = $1;
WHERE accounts.budget_id = $1
ORDER BY accounts.name;
-- name: GetAccountsWithBalance :many
SELECT accounts.id, accounts.name, SUM(transactions.amount)::decimal(12,2) as balance
@ -18,4 +19,5 @@ FROM accounts
LEFT JOIN transactions ON transactions.account_id = accounts.id
WHERE accounts.budget_id = $1
AND transactions.date < NOW()
GROUP BY accounts.id, accounts.name;
GROUP BY accounts.id, accounts.name
ORDER BY accounts.name;