vendredi 5 février 2016

is it possible to order by column based on values, in sqlite?

suppose this is my table

name    status
ab      1
cd      4
ef      -2
mn      3
pq      -1
xy      2

defination of status:

1,2     = success
3,4     = failure
-1,-2   = error

expected results after order by (order by status based on success, failure, error)

ab      1
xy      2
cd      4
mn      3
ef      -2
pq      -1

while simple order status by gives this

ab      1
xy      2
mn      3
cd      4
pq      -1
ef      -2

Is there a way to sort in expected way, without adding a column that maps similar status to a certain value?

Aucun commentaire:

Enregistrer un commentaire