Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id CA140B5DC5D for ; Mon, 17 Oct 2011 17:44:42 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 85214-01 for ; Mon, 17 Oct 2011 20:44:36 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mail.postgresql.org (Postfix) with ESMTP id 95DE9B5DC5C for ; Mon, 17 Oct 2011 17:44:36 -0300 (ADT) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1RFu30-00029t-MM for pgsql-sql@postgresql.org; Mon, 17 Oct 2011 22:44:34 +0200 Received: from g224125007.adsl.alicedsl.de ([92.224.125.7]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 17 Oct 2011 22:44:34 +0200 Received: from tim by g224125007.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 17 Oct 2011 22:44:34 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: pgsql-sql@postgresql.org To: pgsql-sql@postgresql.org From: Tim Landscheidt Subject: Re: postgres sql help Date: Mon, 17 Oct 2011 20:44:21 +0000 Organization: Lines: 34 Message-ID: References: <86obxhtkd1.fsf@protecting.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: g224125007.adsl.alicedsl.de Mail-Copies-To: never User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:mEeeZNWFlBm/3uHcwfqHxCUxHJs= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.404 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-0.504 X-Spam-Level: X-Archive-Number: 201110/27 X-Sequence-Number: 35911 Harald Fuchs wrote: >> 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. Really neat! :-) For pre-9.1, you have to "ORDER BY string_to_array(TRIM('.' FROM ver_no), '.')::int[];", though. Tim