Antw: ORDER BY using specifc values

From: "Gerhard Dieringer" <DieringG(at)eba-haus(dot)de>
To: <ian(at)blazingcactus(dot)com>, <pgsql-sql(at)postgresql(dot)org>
Subject: Antw: ORDER BY using specifc values
Date: 2000-04-13 06:32:59
Message-ID: s8f5865a.009@kopo001
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


Ian McWilton wrote:

> ...
>
> 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.
> ...

I'm not sure, if I understood yor problem, but could the following be a solution:

create table sort_table (sf int, value char(1));
insert into sort_table(1,'C');
insert into sort_table(2,'A');
insert into sort_table(3,'B');

select y.INDEX, y.VALUE, s.sf
from your_table y, sort_table s
where y.value = s.value
order by s.sf;

------------
Gerhard

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2000-04-13 07:03:20 Re: ORDER BY using specifc values
Previous Message Peter Eisentraut 2000-04-13 02:05:15 Re: Localization or an other solution