This is the method used in my database adapter :
------------------------------------------------------------------
public Cursor getBiggestInTheColumn() {
return db.query(DATABASE_TABLE, null,
"MAX(price)", null, null, null, null);
}
------------------------------------------------------------------
It should work but when i call the method :
---------------------------------------------------------------------
cursor = dbadp.getBiggestInTheColumn();
--------------------------------------------------------------------
I Get a Runtime Error Like This(LogCat) :
07-14 12:38:51.852: ERROR/AndroidRuntime(276): Caused by:
android.database.sqlite.SQLiteException: misuse of aggregate function
MAX(): , while compiling: SELECT * FROM spendings WHERE MAX(price)
Any ideas? I suspect this is due to the bad query, but this is the
best one that i can come up with. Other queries are working well. Also
the table has some data in it. I know i should look documentation but
i'm out of time.
I've been given an advice to use rawQuery() instead, so i changed the
query to :
-------------------------------------------------------------------
db.rawQuery("SELECT MAX(price) FROM spendings", null);
-------------------------------------------------------------------
I guess it solved the problem but now it returns me this :
ERROR/AndroidRuntime(335): Caused by:
android.database.CursorIndexOutOfBoundsException: Index -1 requested,
with a size of 1
Thank you in advance.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en