make zero appear last in a list of ascending numbers

后端 未结 5 1248
悲哀的现实
悲哀的现实 2020-12-19 22:06

I\'m using SQLite in an Android application.
In all of my tables I have a default row with an index of 0 that holds default values for that table.
In most situations

5条回答
  •  天涯浪人
    2020-12-19 22:43

    Try this:

    ORDER BY
        CASE epoch_date.epoch WHEN 0 THEN 1 ELSE 0 END,
        epoch_date.epoch
    

    I haven't tested in SQLite but works in many other databases so hopefully it should work in SQLite too.

提交回复
热议问题