select * from table1
order by case Language when null then 1 else 0 end, Language
No matter which way I play around with it, it always displays null values first. Is there a standard way to allow non null values to take ordering precedence?
Thanks guys
You don't need
WHEN
:Operator
IS
will return 1 on true, 0 otherwise (Operators).EDIT: Dealing with empty
TEXT
, also:ORDER BY
clause uses two fields:Language IS NULL OR Language=''
. That's a boolean expression (resulting in0
(false) or1
(true) in SQLite), same as(Language IS NULL) OR (Language='')
When first field has same results, second fiels is used:
Language
.This way, whenever
Language
isNULL
or emptyTEXT
, first field will be1
, relying those results after other results, evaluated to0
. Then, second field is used to sort all results whichLanguage
has content.This is an extension of LS_dev's answer to UNIONs. Not a nice way, but I can't figure out any other way to make it work, since the documentation says:
You have to use the
is
operator when checking fornull