collating advice

From: Laurette Cisneros <laurette(at)nextbus(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: collating advice
Date: 2002-07-11 21:22:30
Message-ID: Pine.LNX.4.44.0207111414390.16757-100000@visor.corp.nextbus.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


How to sort a text column in numerical order?

I have a text column in a table:

...
col2 text
...

which can contains values that are both number and a combination of numeric
and text:

1
1a
2
2a
2b
10
12
12a
etc.

Of course, they aren't entered into the table in any particular order.

A select like this:

select * from tablex order by col2;

returns this:

10
12
12a
1
1a
2a
2b

what we would like to get is:
1
1a
2
2a
2b
10
12
12a

Any ideas on how to achieve this?

Thanks,

--
Laurette Cisneros
The Database Group
(510) 420-3137
NextBus Information Systems, Inc.
www.nextbus.com
----------------------------------
"Intelligence complicates. Wisdom simplifies."
-- Mason Cooley

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2002-07-11 21:38:16 Re: SELECT...FOR UPDATE
Previous Message Andreas Plesner Jacobsen 2002-07-11 20:27:57 Re: SELECT...FOR UPDATE