order by desc - with zeros on top
order by desc - with zeros on top
hiho
IIRC there where recently a sql code snippet, that solved the problem of
"ordering a list of ints descending - but keep the zero on top":
e.g.:
shown_production_id
---------------------
0
0
20270
20258
901
900
if there is no easy way or may memory plays tricks on me: dont bother
with this! i can solve it easily in the app - but why put work where the
dbs can already fix it.
--
cu
Re: order by desc - with zeros on top
От:
Michael Glaesemann <grzm@seespotcode.net>
Дата:
On Jun 14, 2006, at 0:29 , Christoph Frick wrote: > IIRC there where recently a sql code snippet, that solved the > problem of > "ordering a list of ints descending - but keep the zero on top": SELECT shown_production_id FROM wherever ORDER BY shown_production_id = 0 , shown_production_id desc; I don't remember if TRUE sorts before FALSE, but either use = 0 or <> 0. That should work. Michael Glaesemann grzm seespotcode net