From: | Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> |
---|---|
To: | basti <mailinglist(at)unix-solution(dot)de>, pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: postgresql order lowercase before uppercase |
Date: | 2021-03-19 15:58:55 |
Message-ID: | fe4c460dc7e6dc3201a4cfa0893dca2e04143987.camel@cybertec.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, 2021-03-19 at 10:12 +0100, basti wrote:
> >> 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.
>
> This does not work for me. The same result as normal order.
>
> Amm
> andere Marken
> Ani
> Anti
> Bra
> Cali
You are allowed to adapt the query to your special needs.
But if you need to be spoonfed:
SELECT a.name
FROM foo as a
ORDER BY a.name = initcap(a.name), a.name;
Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Kellerer | 2021-03-19 17:11:45 | Re: SELECT is faster on SQL Server |
Previous Message | Jehan-Guillaume de Rorthais | 2021-03-19 15:32:05 | Re: SELECT is faster on SQL Server |