【发布时间】:2011-04-14 05:08:11
【问题描述】:
嘿,我正在尝试查询 cont 列中具有最大值的单词。例如:如果单词 "test1" 在 cont 中的值为 5,而 "test2" 的值为 2,则 "test1" 将显示在第一个位置。明白了吗?
所以。我试图这样做,但它返回以下错误:
09-18 22:24:04.072: ERROR/AndroidRuntime(435): Caused by: android.database.sqlite.SQLiteException: 滥用聚合函数 MAX(): ,编译时:SELECT word FROM words WHERE MAX(cont ) 按顺序排序
这是我的方法:
public List<String> selectMaxCont(){
List<String> list = new ArrayList<String>();
Cursor cursor = this.db.query(TABLE_NAME, new String[]{"word"}, "MAX(cont)", null, null, null, "cont desc");
if(cursor.moveToFirst()){
do{
list.add(cursor.getString(0));
}while(cursor.moveToNext());
}
if(cursor != null && !cursor.isClosed()){
cursor.close();
}
return list;
}
【问题讨论】: