diff --git a/postgres/cumultative-balances.sql.go b/postgres/cumultative-balances.sql.go index 98f3aed..de14e6d 100644 --- a/postgres/cumultative-balances.sql.go +++ b/postgres/cumultative-balances.sql.go @@ -19,7 +19,7 @@ SELECT COALESCE(ass.date, tra.date), COALESCE(ass.category_id, tra.category_id), COALESCE(tra.amount, 0)::decimal(12,2) as transactions FROM assignments_by_month as ass FULL OUTER JOIN transactions_by_month as tra ON ass.date = tra.date AND ass.category_id = tra.category_id -WHERE (ass.budget_id IS NULL OR ass.budget_id = $1) AND (tra.budget_id IS NULL OR tra.budget_id = $1) +WHERE COALESCE(ass.budget_id, tra.budget_id) = $1 ORDER BY COALESCE(ass.date, tra.date), COALESCE(ass.amount, tra.amount) ` diff --git a/postgres/queries/cumultative-balances.sql b/postgres/queries/cumultative-balances.sql index cc22480..4803d8b 100644 --- a/postgres/queries/cumultative-balances.sql +++ b/postgres/queries/cumultative-balances.sql @@ -4,5 +4,5 @@ SELECT COALESCE(ass.date, tra.date), COALESCE(ass.category_id, tra.category_id), COALESCE(tra.amount, 0)::decimal(12,2) as transactions FROM assignments_by_month as ass FULL OUTER JOIN transactions_by_month as tra ON ass.date = tra.date AND ass.category_id = tra.category_id -WHERE (ass.budget_id IS NULL OR ass.budget_id = @budget_id) AND (tra.budget_id IS NULL OR tra.budget_id = @budget_id) +WHERE COALESCE(ass.budget_id, tra.budget_id) = @budget_id ORDER BY COALESCE(ass.date, tra.date), COALESCE(ass.amount, tra.amount); \ No newline at end of file