Merge balance and balanceassignments
This commit is contained in:
@ -21,22 +21,21 @@ WHERE category_groups.budget_id = $1;
|
||||
|
||||
-- name: GetCategoriesWithBalance :many
|
||||
SELECT categories.id, categories.name, category_groups.name as group,
|
||||
COALESCE(
|
||||
(COALESCE(
|
||||
(
|
||||
SELECT SUM(a_hist.amount)
|
||||
FROM assignments a_hist
|
||||
WHERE categories.id = a_hist.category_id
|
||||
AND a_hist.date < @from_date
|
||||
)
|
||||
, 0)::decimal(12,2) as balance_assignments,
|
||||
COALESCE(
|
||||
, 0)+COALESCE(
|
||||
(
|
||||
SELECT SUM(t_hist.amount)
|
||||
FROM transactions t_hist
|
||||
WHERE categories.id = t_hist.category_id
|
||||
AND t_hist.date < @from_date
|
||||
)
|
||||
, 0)::decimal(12,2) as balance,
|
||||
, 0))::decimal(12,2) as balance,
|
||||
COALESCE(
|
||||
(
|
||||
SELECT SUM(t_this.amount)
|
||||
|
Reference in New Issue
Block a user