Skip site navigation (1) Skip section navigation (2)

Re: order by desc - with zeros on top

From: Michael Glaesemann <grzm(at)seespotcode(dot)net>
To: Christoph Frick <frick(at)sc-networks(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: order by desc - with zeros on top
Date: 2006-06-14 04:24:16
Message-ID: 54EC22FA-D89C-4CD3-8146-FD4668F21B2A@seespotcode.net (view raw or flat)
Thread:
Lists: 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




In response to

pgsql-novice by date

Next:From: willfarnabyDate: 2006-06-14 06:18:04
Subject: Can PostgreSQL 8.x Return Multiple "Result Sets" ?
Previous:From: Tom AllisonDate: 2006-06-14 00:19:22
Subject: ruby

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group