Re: postgres sql help

From: Harald Fuchs <hari(dot)fuchs(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: postgres sql help
Date: 2011-10-16 08:24:10
Message-ID: 86obxhtkd1.fsf@protecting.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

In article <SNT102-W49402A41C6B6599F082D35A8E10(at)phx(dot)gbl>,
James Bond <coolofall(at)hotmail(dot)com> writes:

> hi, i am fairly new in postgresql, so if anyone can help me would be great
> if i simply do:

> select ver_no
> from version
> order by ver_no

> the result will be something like this:

> .1.3.1
> .1.3.2.5.
> .1.4.1.7.12
> .1.4.11.14.7.
> .1.4.3.109.1.
> .1.4.8.66.

> so as you can see first 3 lines are ok, but how to make 1.4.3.109 come
> before 1.4.11 because the third level "3" is smaller than "11".

The query

SELECT ver_no
FROM version
ORDER BY string_to_array(ver_no, '.', '')::int[]

should do what you want.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Andreas Kretschmer 2011-10-16 08:27:06 Re: Group by on Date
Previous Message Andreas Kretschmer 2011-10-16 08:11:57 Re: postgres sql help