X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 050CB475AE4 for ; Sun, 13 Apr 2003 02:06:57 -0400 (EDT) Received: from mpls-qmqp-03.inet.qwest.net (mpls-qmqp-03.inet.qwest.net [63.231.195.114]) by postgresql.org (Postfix) with SMTP id 18D5B47580B for ; Sun, 13 Apr 2003 02:06:51 -0400 (EDT) Received: (qmail 72270 invoked by uid 0); 13 Apr 2003 06:05:06 -0000 Received: from mpls-pop-07.inet.qwest.net (63.231.195.7) by mpls-qmqp-03.inet.qwest.net with QMQP; 13 Apr 2003 06:05:06 -0000 Received: from jonesandjoneslaw.com (HELO qwest.net) (63.231.17.185) by mpls-pop-07.inet.qwest.net with SMTP; 13 Apr 2003 06:07:09 -0000 Date: Sat, 12 Apr 2003 18:50:07 -0700 Message-ID: <3E98C24F.1070507@qwest.net> From: "Randolph Jones" To: pgsql-sql@postgresql.org User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 Subject: sort up then down Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-11.8 required=5.0 tests=BAYES_10,DATE_IN_PAST_03_06,USER_AGENT_MOZILLA_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/198 X-Sequence-Number: 12899 I have database fields 1234567891.001; I want to sort on first 10 digits descending; (last date first) then ascending on the last 3 digit (page numbers) the statement below gives the right answer, but is this how to do it? SELECT substr(imgname,1,10) AS name, substring(imgname,12,3) AS pg FROM fax GROUP BY imgname, pg ORDER BY name DESC, pg ASC; TIA rfjones