I am retrieving data from database using select query.My requirement is i have to sum the (total) column where group=household and category=Income.I have 1 entry in database which satisfy this condition.But it returns always 0.Please help me.
My query is:
long sum=0;
Cursor cursor1 = db.rawQuery(
"SELECT SUM("+(KEY_TOTAL)+") FROM incomexpense WHERE groups='Household' & category='Income'",null);
if(cursor1.moveToFirst())
{
sum = cursor1.getLong(0);
}
cursor1.close();
String housetotal=String.valueOf((long)sum);
System.out.println("house="+housetotal);
Try replacing the
&withANDin the query.