ORDER BY using specifc values

From: Ian McWilton <ian(at)blazingcactus(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: ORDER BY using specifc values
Date: 2000-04-12 23:31:18
Message-ID: 200004122331.QAA05037@hedley.blazingcactus.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message tjk@tksoft.com 2000-04-12 23:31:19 Re: Localization or an other solution
Previous Message tjk@tksoft.com 2000-04-12 23:14:30 Re: Localization or an other solution