From f5c6857d7178f1e50a88f437aa536d9103adebe5 Mon Sep 17 00:00:00 2001 From: Billy Brawner Date: Sat, 1 Jun 2019 20:54:13 -0700 Subject: [PATCH] Fix transaction sum query --- .../wbrawner/budgetserver/transaction/TransactionRepository.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/wbrawner/budgetserver/transaction/TransactionRepository.kt b/src/main/kotlin/com/wbrawner/budgetserver/transaction/TransactionRepository.kt index 0746ec2..b808cae 100644 --- a/src/main/kotlin/com/wbrawner/budgetserver/transaction/TransactionRepository.kt +++ b/src/main/kotlin/com/wbrawner/budgetserver/transaction/TransactionRepository.kt @@ -13,7 +13,7 @@ interface TransactionRepository: PagingAndSortingRepository { fun findAllByAccountAndCategory(account: Account, category: Category): List @Query( nativeQuery = true, - value = "SELECT (COALESCE((SELECT SUM(amount) from transaction WHERE is_expense = 0), 0)) - (COALESCE((SELECT SUM(amount) from transaction WHERE is_expense = 1), 0));" + value = "SELECT (COALESCE((SELECT SUM(amount) from transaction WHERE expense = 0), 0)) - (COALESCE((SELECT SUM(amount) from transaction WHERE expense = 1), 0));" ) fun sumBalanceByAccount(account: Account): Long } \ No newline at end of file