X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B4C70D1B504 for ; Wed, 15 Oct 2003 15:41:53 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 75791-09 for ; Wed, 15 Oct 2003 12:41:22 -0300 (ADT) Received: from beamish.nsd.ca (beamish.nsd.ca [205.150.156.194]) by svr1.postgresql.org (Postfix) with ESMTP id 615E2D1B531 for ; Wed, 15 Oct 2003 12:41:21 -0300 (ADT) Received: (from smap@localhost) by beamish.nsd.ca (8.9.3/8.9.3) id LAA03136; Wed, 15 Oct 2003 11:41:19 -0400 X-Authentication-Warning: beamish.nsd.ca: smap set sender to using -f Received: from reddog.nsd.ca(192.168.101.30) by beamish.nsd.ca via smap (V2.1/2.1+anti-relay+anti-spam) id xma003134; Wed, 15 Oct 03 11:40:58 -0400 Received: from nsd.ca (jllachan-linux.nsd.ca [192.168.101.148]) by reddog.nsd.ca (8.8.7/8.8.7) with ESMTP id LAA11716; Wed, 15 Oct 2003 11:26:23 -0400 Message-ID: <3F8D6B03.83A186EE@nsd.ca> Date: Wed, 15 Oct 2003 11:42:59 -0400 From: Jean-Luc Lachance X-Mailer: Mozilla 4.8 [en] (X11; U; Linux 2.4.18-24.7.x i686) X-Accept-Language: en MIME-Version: 1.0 To: "George A.J" Cc: pgsql-sql@postgresql.org Subject: Re: Sorting problem References: <20031015033054.50872.qmail@web14908.mail.yahoo.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/176 X-Sequence-Number: 15576 You are obviously not using C locale. If you can't change it for some reason, you can use: select * from accounts order by int4( trim( acno, '#')); JLL "George A.J" wrote: > > hi all, > i am using postgres 7.3.2 .i am converitng a mssql database to > postgres. > now i am facing a strange problem. sorting based on a varchar field is > not working > as expected. the non alphanumeric characters are not sorting based on > the ascii > value of them. > > i have the following table structure.. > > create table accounts > ( > AcNo varchar (10), > Name varchar(100), > balance numeric(19,4) > ) > > when i used the query select * from accounts order by acno. the > result is not correct > > suppose that the acno field contains values '###1' ,'###2' ,'##10' , > '#100' > the sort order in postgres is > '###1' > '##10' > '#100' > '###2' > But i want the result as follows > '###1' > '###2' > '##10' > '#100' > > that means the ascii value of # should be considered for sorting.. > what is the problem. is it the behaviour of postgres. > do i need to change any configuration. i am using all default > configurations > or is it a bug...? > the problem actually is of < & > operators for varchar. > > in a simple comparison > > select '###2' < '##10' > > returns false but i need true. > > is there any solution exist. even if i replaced # with any non > alphanumeric > character the result is same.. > > pls help > > jinu jose > > ---------------------------------------------------------------------- > Do you Yahoo!? > The New Yahoo! Shopping - with improved product search