Re: postgresql order lowercase before uppercase

From: basti <mailinglist(at)unix-solution(dot)de>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: postgresql order lowercase before uppercase
Date: 2021-03-19 09:12:33
Message-ID: dd09e24e-f89b-2a65-4246-e2c3babae49e@unix-solution.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 19.03.21 08:33, Laurenz Albe wrote:
> On Thu, 2021-03-18 at 23:51 +0100, basti wrote:
>> Am 18.03.21 um 17:19 schrieb Laurenz Albe:
>>> On Thu, 2021-03-18 at 15:39 +0100, basti wrote:
>>>> I need to as follow:
>>>>
>>>> ande
>>>> Amma
>>>> Anit
>>>> Anti
>>>> Brac
>>>> Cali
>>>> ....
>>>
>>> Create an ICU collation:
>>>
>>> CREATE COLLATION inv (PROVIDER = icu, LOCALE = "en-US(at)CaseFirst=LowerFirst");
>>
>> I have try the inv collate, that does not work on PG 9.6 and 10.
>>
>> Order is the same as without collate.
>>
>> SELECT a.name
>> FROM foo as a
>> LEFT JOIN (SELECT name from foo WHERE name = 'lowercase name') as b
>> on a.name = b.name
>> ORDER by b.name,a.name
>>
>> does it.
>>
>> perhaps there is a better way?
>
> Ah, I misunderstood what you want.
>
> SELECT a.name
> FROM foo as a
> ORDER BY a.name <> lower(a.name), a.name;
>
> That works because FALSE < TRUE.
>
> Yours,
> Laurenz Albe
>

This does not work for me. The same result as normal order.

Amm
andere Marken
Ani
Anti
Bra
Cali

Test data attached.

Attachment Content-Type Size
table.sql application/sql 969 bytes

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Frank Millman 2021-03-19 09:16:50 Re: SELECT is faster on SQL Server
Previous Message Thomas Kellerer 2021-03-19 09:04:10 Re: SELECT is faster on SQL Server