Re: SQL specified sort

From: "tjk(at)tksoft(dot)com" <tjk(at)tksoft(dot)com>
To: morrisonjeffrey(at)hotmail(dot)com (jeffrey morrison)
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: SQL specified sort
Date: 2001-05-28 13:29:15
Message-ID: 200105281329.GAA11700@smtp3.tksoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Jeff,

If you want to receive your data in an order which
you specify manually, the easiest way to accomplish this
is to add a separate field which contains an int4 value
used by you to specify the order.

E.g.

myval | sortint
_____________________
H29 | 2
214 | 1
200 | 3
099 | 4

SELECT myval FROM mytable ORDER BY sortint;

Troy

>
> I was wondering if you could help me out with a problem I'm having. Say for
> example I have data coming out like:
> H29
> 214
> 200
> 099
>
> How would I use a sort to be able to make the output look like
>
> 214
> H29
> 200
> 099
>
> I don't believe their is a way to do an ORDER BY in a specific order. Any
> help you could give me this problem would be very much appreciated.
>
> Jeff Morrison
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Vladislav Breus 2001-05-28 14:03:32 sql user management
Previous Message Martín Marqués 2001-05-28 12:46:20 Re: Seq Scan