vendredi 27 mars 2015

Android Studio SQLite Column Sum

I have a table with several columns and I'm looking to create a function that will return the sum of all the entries in a particular column.


For debug purposes, I've simply set the return string to "1" to confirm the rest of my code works properly, which it does.


Can anyone help me with the necessary code to sum the column and return the value?



public String TotalServings(){
SQLiteDatabase db = getReadableDatabase();

//From the table "TABLE_PRODUCTS" I want to sum all the entries in the column "COLUMN_SERVINGS"

String Servings = "1";
return Servings;
}

Aucun commentaire:

Enregistrer un commentaire