Re: order by desc - with zeros on top - Mailing list pgsql-novice

From Michael Glaesemann
Subject Re: order by desc - with zeros on top
Date
Msg-id 54EC22FA-D89C-4CD3-8146-FD4668F21B2A@seespotcode.net
Whole thread Raw
In response to order by desc - with zeros on top  (Christoph Frick <frick@sc-networks.com>)
List pgsql-novice
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




pgsql-novice by date:

Previous
From: Christoph Frick
Date:
Subject: order by desc - with zeros on top
Next
From: chelsea boot
Date:
Subject: Replacing data