这看起来像一个非常基本的查询,在我的桌面上工作正常,但在Android上执行时没有排序结果:
SELECT column1, SUM(column2) AS column3
FROM ftdata WHERE ftdata MATCH 'column1:example'
GROUP BY column1
ORDER BY SUM(column2) DESC
LIMIT 8
我也尝试将它包装在内部表中无济于事:
SELECT * FROM(
SELECT column1, SUM(column2) AS column3
FROM ftdata WHERE ftdata MATCH 'column1:example'
GROUP BY column1) X
ORDER BY X.column3 DESC
LIMIT 8
这是我用来运行查询的代码,以防它有用:
Cursor c = mDb.rawQuery(sql, null);
if(c != null && c.moveToFirst()) {
do {
results.add(c.getString(0));
}
while(c.moveToNext());
}
c.close();
我还应该澄清ftdata
是用于FTS查询的虚拟表。其定义如下:
CREATE VIRTUAL TABLE ftdata USING fts3(
column1,
column2 int)
答案 0 :(得分:2)
尝试使用它:
SELECT column1, SUM(column2) AS my_sum
FROM ftdata WHERE ftdata MATCH 'column1:example'
GROUP BY column1
ORDER BY my_sum DESC
LIMIT 8