ORDER BY using specifc values - Mailing list pgsql-sql

From Ian McWilton
Subject ORDER BY using specifc values
Date
Msg-id 200004122331.QAA05037@hedley.blazingcactus.com
Whole thread Raw
Responses Re: ORDER BY using specifc values  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: ORDER BY using specifc values  (Oliver Mueschke <o@mueschke.de>)
List pgsql-sql
Hi there,

I need to return the results of a SELECT ordered by a 
column but in a way that is neither ascending or 
descending. 

The ORDER BY column can have one of five values and I 
want to specify which values are returned in the list 
in which order.

An example table below shows the data in the DB:

INDEX | VALUE
1, A
2, B
3, B
4, C
5, B

...and what I want is for my queries result to be 
ordered by VALUE with C put first in the list, then A, 
then B.

Having investigated it appears that ORDER BY does not 
seem to be any help as it restricts the ordering to ASC 
or DESC.

The onyl solution I can see isn't at all elegant; issue 
five SELECT statements in sequence and construct one 
list from this five

Does anyone know of another way to do what I want in 
one query?

Regrads,



Ian McWilton.


pgsql-sql by date:

Previous
From: "tjk@tksoft.com"
Date:
Subject: Re: Localization or an other solution
Next
From: Peter Eisentraut
Date:
Subject: Re: Localization or an other solution