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
Can you add an extra column to act as a filter, then sort by both columns?
select (...)epoch_date.epoch, case epoch_date.epoch when 0 then 1 else 0 as default
(...)
order by default,epoch_date.epoch
Equivalent to the CASE
statement suggestion, but shorter:
ORDER BY epoch_date.epoch == 0, epoch_date.epoch
I'm not completely sure if SQLite allows case statements in "order by", but try something along these lines:
order by case epoch_date.epoch when 0 then 999999 else epoch_date.epoch end
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.
order by decode(epoch_date.epoch,0,null,epoch_date.epoch)
you can use something like this..since nulls are kept in the end in case of ascending order. provided you have decode function available in sqlite..or else you can just use a case statement instead.
Ravi Kumar