Android SQLite排序规则

Android SQLite排序规则,android,sqlite,sql-order-by,coalesce,Android,Sqlite,Sql Order By,Coalesce,我有一个android中的SQLite数据库和一些表,其中一个是: trainings (date TEXT, exercise TEXT, repetitions INTEGER, weight REAL) 它有两个指标,重量和重复都是ASC 就是这样,在一个按重复顺序排列的select语句中,我得到了如下结果: Select * from trainings WHERE exercise='"+exercise+"' AND repetitions != '-' AND repetitio

我有一个android中的SQLite数据库和一些表,其中一个是:

trainings (date TEXT, exercise TEXT, repetitions INTEGER, weight REAL)
它有两个指标,重量和重复都是ASC

就是这样,在一个按重复顺序排列的select语句中,我得到了如下结果:

Select * from trainings WHERE exercise='"+exercise+"' AND repetitions != '-' AND repetitions != 0 ORDER BY COALESCE( weight, date);

0
0
0
12
13
25
-
-
... ORDER BY
      CASE COALESCE(weight, date)
        WHEN '-' THEN 0
        ELSE          COALESCE(weight, date)
      END
我想知道是否有可能将“-”结果放在最后,而不是最后,因为在我的应用程序中,我将0和“-”视为同一事物,我必须将这两个数据放在一起


有什么建议吗?提前感谢

要将任意值转换为其他任意值,请使用;大概是这样的:

Select * from trainings WHERE exercise='"+exercise+"' AND repetitions != '-' AND repetitions != 0 ORDER BY COALESCE( weight, date);

0
0
0
12
13
25
-
-
... ORDER BY
      CASE COALESCE(weight, date)
        WHEN '-' THEN 0
        ELSE          COALESCE(weight, date)
      END

我想如果我只选择一个结果为“-”和0的选项,然后在我的问题中重复选择!='-'还有重复=这也许可以解决,但我认为这不是最好的办法