Alternatives to sign() in sqlite for custom order by
Posted
by Pentium10
on Stack Overflow
See other posts from Stack Overflow
or by Pentium10
Published on 2010-05-19T10:45:43Z
Indexed on
2010/05/19
10:50 UTC
Read the original article
Hit count: 190
I have a string column which contains some numeric fields, but a lot are 0, empty string or null. The rest are numbers having different range, all positive.
I tried to create a custom order by. The order would be done by two fields. First I would like to order the fields that have this number >0 and then sort by name.
So something this would work:
select * from table
order by sign(referenceid) desc, name asc;
But Sqlite lacks the sign() -1/0/1 function, and I am on Android and I can't create user defined functions. What other options I have to get this sort done.
© Stack Overflow or respective owner