From: | Pierre LEBRECH <pierre(dot)lebrech(at)laposte(dot)net> |
---|---|
To: | "Roberts, Jon" <Jon(dot)Roberts(at)asurion(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: How to sort strings containing a dot? |
Date: | 2008-03-25 16:05:23 |
Message-ID: | 47E922C3.3000407@laposte.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Thanks Jon, but it does not give me what I want.
But, this gave me an idea : I replaced the select statement by this one :
select name from t order by replace(name, '.', 'z');
And this time it works. With 'z', I get 'co' before 'com'. If I set an 'a', then I get the 'com' before 'co'. Cool!
examples :
dns=> select name from t order by replace(name, '.', 'z');
name
----------
com
com.enta
co.aaa
co.abb
co.cab
co.ment
(6 lines)
dns=> select name from t order by replace(name, '.', 'a');
name
----------
co.aaa
co.abb
co.cab
co.ment
com
com.enta
(6 lines)
Thank you.
Roberts, Jon wrote :
> create table t (name varchar);
>
> insert into t values ('co.aaa');
> insert into t values ('co.abb');
> insert into t values ('co.cab');
> insert into t values ('com');
> insert into t values ('co.ment');
> insert into t values ('com.enta');
>
> select name from t order by replace(name, '.', '');
>
>
> Jon
>
>> -----Original Message-----
>> From: pgsql-general-owner(at)postgresql(dot)org [mailto:pgsql-general-
>> owner(at)postgresql(dot)org] On Behalf Of Pierre LEBRECH
>> Sent: Tuesday, March 25, 2008 9:56 AM
>> To: pgsql-general(at)postgresql(dot)org
>> Subject: [GENERAL] How to sort strings containing a dot?
>>
>> Hello,
>>
>> I want to sort strings containing a dot but by taking care of this dot
>> like any other character.
>>
>> example :
>>
>> Currently, I get this after the sort :
>>
>> co.aaa
>> co.abb
>> co.cab
>> com
>> co.ment
>> com.enta
>>
>> But I would like to get this :
>>
>> co.aaa
>> co.abb
>> co.cab
>> co.ment
>> com
>> com.enta
>>
>> How I can do this?
>> Thank you
>>
>>
>> --
>> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-general
>
From | Date | Subject | |
---|---|---|---|
Next Message | Craig Ringer | 2008-03-25 16:08:13 | Re: return value from SQL statement |
Previous Message | Tom Lane | 2008-03-25 15:58:47 | Re: How to sort strings containing a dot? |