my table look like this:
Client_Code Oder_ID NoOrd Weight
850458 5 1 12
850458 5 2 12
850458 6 1 5
i want to sum the Weight, but unique par Oder_ID. so the resultat that i want is 17 = 12 + 5 not 29
how can i do that ?
my code like this;
public int GetPoids()
{
String SQL_syntax = "SELECT SUM("+ DBHelper.KEY_Poids +") as SumPoids FROM " + DBHelper.tableName + " GROUP BY " + DBHelper.KEY_CodeClient +","+DBHelper.KEY_NoOrdre ;
Cursor c = database.rawQuery(SQL_syntax, null);
if (c != null)
c.moveToFirst();
int Poids = c.getInt(0);
c.close();
return Poids;
}
Aucun commentaire:
Enregistrer un commentaire