title: How to use th SUM function to return the values from sqlite DB in android?
body: <p>In my application, store the amount details of company in my sq lite DB.For example om my first position of DB in name column-company 1,total column - 400,second position of DB in name column-company 2,total column - 800,third position of DB in name column-company 1,total column - 500.how Sum the company 1 details only to return the total amount.</p>
  
  <p>My main coding is,</p>
  
  <pre><code>String str = db.company_amount("Company 1");
  Log.v("Total", ""+str);
  </code></pre>
  
  <p>My DB coding is,</p>
  
  <pre><code>String company_amount(String name){
  
  SQLiteDatabase db = this.getReadableDatabase();
  
  String s = "";
  Cursor cursor = db.rawQuery("SELECT SUM(KEY_AMOUNT) FROM TABLE_BILL_DETAILS WHERE = ?", new String[] {String.valueOf(name)});
  
  if (cursor != null) {
  
      if (cursor.moveToNext()) {
          s = cursor.getString(1);
          return cursor.getString(1);
      }
      cursor.close();
  
  }
  
  return s;
  }
  </code></pre>
  
  <p>It shows some error,I don't know how to return the values.Can any one know please help me to solve this problem.</p>
  
  <p>My Logcat Error</p>
  
  <pre><code>04-25 14:54:06.701: E/AndroidRuntime(2776): FATAL EXCEPTION: main
  04-25 14:54:06.701: E/AndroidRuntime(2776): java.lang.RuntimeException: Unable to start activity 
  
  ComponentInfo{invoicebill.details/invoicebill.details.Total_company_details}:                  android.database.sqlite.SQLiteException: near "=": syntax error: , while compiling: SELECT SUM(KEY_AMOUNT) FROM TABLE_BILL_DETAILS WHERE = ?
  </code></pre>