Database retrieval in Android causing error -


In my application, I need to get data from the database. I need to get the data satisfying the condition that my The total column is the amount of the column where the group column should be domestic.

I have written this question:

  public string adhown () {long sum = 0; Cursor cursor 1 = db.rawQuery ("SELECT SUM (" + (KEY_TOTAL + ") from income tax where groups = earnings", blank); If (cursor1.moveToFirst ()) {sum = cursor1.getLong (0); } Cursor 1 Close (); String home = String.valueOf (long) yoga); Println ("home =" + housetotal); Return homeman; }   

But I get an error:

java.lang.RuntimeException: Unable to start activity ComponentInfo {com.budget1 / com.budget1. Report}:
android.database.sqlite.SQLiteException: There is no such column: Earnings: when compiling: Select SUM (total) from income tax WHERE groups = earnings
I am new to this because please help me in advance

The query should be:

  cursor cursor 1 = db.rawQuery ("SELECT SUM (" + (KEY_TOTAL +) "from income tax where groups = 'I' ', blank);   

If (income) is a string .. and if not, then you should ensure that the column exists.

Comments