Simplify query

This commit is contained in:
2022-04-22 18:39:28 +00:00
committed by Gitea
parent 07c0c56d11
commit 777520e9df
2 changed files with 17 additions and 66 deletions

View File

@ -48,8 +48,8 @@ FROM transactions_by_month
WHERE transactions_by_month.budget_id = @budget_id;
-- name: GetProblematicTransactions :many
SELECT *
FROM transactions
SELECT transactions.*
FROM display_transactions AS transactions
LEFT JOIN accounts
ON transactions.account_id = accounts.id
LEFT JOIN transactions AS otherGroupTransaction
@ -57,7 +57,7 @@ LEFT JOIN transactions AS otherGroupTransaction
AND transactions.id != otherGroupTransaction.id
AND transactions.account_id != otherGroupTransaction.account_id
LEFT JOIn accounts AS otherGroupAccount
ON otherGroupTransaction.account_id = accounts.id
ON otherGroupTransaction.account_id = otherGroupAccount.id
WHERE transactions.category_id IS NULL
AND accounts.on_budget
AND (otherGroupAccount.id IS NULL OR NOT otherGroupAccount.on_budget)