Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id BD8DDB5DBCE for ; Sun, 16 Oct 2011 05:24:35 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 87098-03 for ; Sun, 16 Oct 2011 08:24:25 +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 31B79B5D80B for ; Sun, 16 Oct 2011 05:24:24 -0300 (ADT) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1RFM19-0006Uo-2a for pgsql-sql@postgresql.org; Sun, 16 Oct 2011 10:24:23 +0200 Received: from 212.126.222.122 ([212.126.222.122]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 16 Oct 2011 10:24:23 +0200 Received: from hari.fuchs by 212.126.222.122 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 16 Oct 2011 10:24:23 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: Harald Fuchs Subject: Re: postgres sql help Date: Sun, 16 Oct 2011 10:24:10 +0200 Lines: 29 Message-ID: <86obxhtkd1.fsf@protecting.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 212.126.222.122 X-Archive: encrypt User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:8qVJCXnQIiWD4HErRP1JjsJwDyI= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.229 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_NUMERIC_HELO=1.164, RP_MATCHES_RCVD=-0.504, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201110/24 X-Sequence-Number: 35908 In article , James Bond 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.