Page 1 of 1

Sqlite with Sum support?

Posted: Tue Sep 26, 2017 3:50 pm
by Dummy1912
Hello,

Can someone helpme please
i need to know how we can use the SUM function with our column table

for example i need to calculate the Amount of all records but need to split them if row contains 1,2,3
accounts.type:
id,name
1 = Expense
2 = Income
3 = Refund

so how can we sum every amount of 1 ,2 ,3 in 1 single command?
and get the output to an Double

MyFunctions.iIncome = 0
MyFunctions.iExpense = 0
MyFunctions.iRefund = 0
Code: Select all
            Dim attributes As String = "Transactions.setdate,category.name,transactions.amount,transactions.description,transactions.id,groups.type,vendors.name,transactions.status,accounts.type"

            Dim whereClause As String = "transactions.category ='" & CurrentStatementsButton.Name & "' AND transactions.monthid ='" & CurrentStatementsButton.mMonthID & "' AND transactions.yearid ='" & CurrentStatementsButton.mYearID & "'"
            Dim fromClause As String = "LEFT JOIN category ON transactions.category=category.id LEFT JOIN groups ON transactions.type=groups.id LEFT JOIN vendors ON transactions.vendor=vendors.id LEFT JOIN accounts ON transactions.account=accounts.id"

            Dim empls As SQLiteDataReader = DataBase.executeQuery("SELECT " & attributes & " FROM transactions " & fromClause & " WHERE " & whereClause & " ORDER BY transactions.placecount ASC;")


Thanks