• Top Members
    Reps
    Posts
  • 834 Replies
    2585 Replies
  • 716 Replies
    2025 Replies
  • 331 Replies
    1928 Replies

Sqlite with Sum support?

Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
User avatar
Dummy1912
VIP - Donator
Posts: 1965

Sqlite with Sum support?

Tue Sep 26, 2017 4:50 pm

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

Post Reply

Return to “Tutorial Requests”