Add query to find problematic transactions
This commit is contained in:
@ -45,4 +45,19 @@ AND accounts.id = transactions.account_id;
|
||||
-- name: GetTransactionsByMonthAndCategory :many
|
||||
SELECT *
|
||||
FROM transactions_by_month
|
||||
WHERE transactions_by_month.budget_id = @budget_id;
|
||||
WHERE transactions_by_month.budget_id = @budget_id;
|
||||
|
||||
-- name: GetProblematicTransactions :many
|
||||
SELECT *
|
||||
FROM transactions
|
||||
LEFT JOIN accounts
|
||||
ON transactions.account_id = accounts.id
|
||||
LEFT JOIN transactions AS otherGroupTransaction
|
||||
ON transactions.group_id = otherGroupTransaction.group_id
|
||||
AND transactions.id != otherGroupTransaction.id
|
||||
AND transactions.account_id != otherGroupTransaction.account_id
|
||||
LEFT JOIn accounts AS otherGroupAccount
|
||||
ON otherGroupTransaction.account_id = accounts.id
|
||||
WHERE transactions.category_id IS NULL
|
||||
AND accounts.on_budget
|
||||
AND (otherGroupAccount.id IS NULL OR NOT otherGroupAccount.on_budget);
|
Reference in New Issue
Block a user