Re: sort question

Lists: pgsql-jdbc
From: Glenn Holmer <gholmer(at)weycogroup(dot)com>
To: Postgres JDBC list <pgsql-jdbc(at)postgresql(dot)org>
Subject: sort question
Date: 2003-12-16 17:33:27
Message-ID: 3FDF41E7.3010302@weycogroup.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

I don't know if this is a JDBC thing or not, but if I issue this
query:

select distinct style, color, width, size from skiddata
where skidno = 'F3932' order by style, color, width, size;

I get the sizes in order '10 ', '10-', '11 ', '12 ', ' 9 ',
' 9-'. Shouldn't ' 9 ' and ' 9-' come first? Have I got
something set up wrong in Postgres?

I'm using Postgres 7.3.2 on SuSE Linux 8.2 (kernel 2.4.20), driver
pg73jdbc3.jar.

--
____________________________________________________________
Glenn Holmer gholmer(at)weycogroup(dot)com
Programmer/Analyst phone: 414.908.1809
Weyco Group, Inc. fax: 414.908.1601


From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: Glenn Holmer <gholmer(at)weycogroup(dot)com>
Cc: Postgres JDBC list <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: sort question
Date: 2003-12-16 17:41:41
Message-ID: 1071596501.1686.525.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Glenn,

How come there are spaces in there? ' 9 ' ?

what happens if you trim(sizes) ?

Dave
On Tue, 2003-12-16 at 12:33, Glenn Holmer wrote:
> I don't know if this is a JDBC thing or not, but if I issue this
> query:
>
> select distinct style, color, width, size from skiddata
> where skidno = 'F3932' order by style, color, width, size;
>
> I get the sizes in order '10 ', '10-', '11 ', '12 ', ' 9 ',
> ' 9-'. Shouldn't ' 9 ' and ' 9-' come first? Have I got
> something set up wrong in Postgres?
>
> I'm using Postgres 7.3.2 on SuSE Linux 8.2 (kernel 2.4.20), driver
> pg73jdbc3.jar.


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Glenn Holmer <gholmer(at)weycogroup(dot)com>, Postgres JDBC list <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: sort question
Date: 2003-12-16 18:00:25
Message-ID: 200312161900.25944.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Glenn Holmer wrote:
> I don't know if this is a JDBC thing or not,

It is not.

> select distinct style, color, width, size from skiddata
> where skidno = 'F3932' order by style, color, width, size;
>
> I get the sizes in order '10 ', '10-', '11 ', '12 ', ' 9 ',
> ' 9-'. Shouldn't ' 9 ' and ' 9-' come first? Have I got
> something set up wrong in Postgres?

Text fields are sorted textually. If you want a numeric sort, use a
numeric data type.