Android get sum of database column

后端 未结 1 1480
南旧
南旧 2020-12-03 16:13

I need help with summing all the values in one of the columns(amount) in my database. i can a get a particular value. .but i need sum of a specific column, somebody tell me

相关标签:
1条回答
  • 2020-12-03 16:45

    Do so:

    Cursor cur = db.rawQuery("SELECT SUM(myColumn) FROM myTable", null);
    if(cur.moveToFirst())
    {
        return cur.getInt(0);
    }
    
    0 讨论(0)
提交回复
热议问题